From 6b54911a6c9c8637873b4839f69a3817e53cda3c Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Thu, 11 Jun 2026 20:32:32 +0200 Subject: [PATCH 01/86] fix(ci): make the Nix build work with NES_ENABLE_MEOS=OFF and stock paho-mqtt-cpp The Nix environment provides paho-mqtt-cpp as a shared-only library and does not include libmeos. Four changes make the build pass: - flake.nix: add stock paho-mqtt-c + paho-mqtt-cpp to baseThirdPartyDeps; pass -DNES_ENABLE_MEOS=OFF in both defaultPackage and devShell cmakeFlags. - nes-plugins/CMakeLists.txt: introduce NES_ENABLE_MQTT and NES_ENABLE_MEOS options that gate the respective plugin subdirectories via activate_optional_plugin(). - nes-plugins/Sources/MQTTSource, nes-plugins/Sinks/MQTTSink: select PahoMqttCpp::paho-mqttpp3-static when available, fall back to the shared PahoMqttCpp::paho-mqttpp3 target (Nix only ships the shared variant). - nes-physical-operators: gate all MEOS-specific add_plugin calls and the nes-meos link behind if(NES_ENABLE_MEOS) in three CMakeLists files (top-level, Functions/Meos, Aggregation/Function/Meos). - CMakeLists.txt (root): declare option(NES_ENABLE_MEOS) and add_compile_definitions(NES_ENABLE_MEOS) before the nes-* subdirectory loop so the preprocessor symbol is visible to all sibling components. - nes-query-optimizer/LowerToPhysicalWindowedAggregation.cpp: guard the TemporalSequenceAggregationPhysicalFunction include and instantiation with #ifdef NES_ENABLE_MEOS so the translation unit compiles and links when MEOS is disabled. --- CMakeLists.txt | 7 +++ flake.nix | 4 ++ nes-physical-operators/CMakeLists.txt | 6 +- .../Aggregation/Function/Meos/CMakeLists.txt | 2 + .../src/Functions/Meos/CMakeLists.txt | 2 + nes-plugins/CMakeLists.txt | 55 ++++++++++--------- nes-plugins/Sinks/MQTTSink/CMakeLists.txt | 9 ++- nes-plugins/Sources/MQTTSource/CMakeLists.txt | 9 ++- .../LowerToPhysicalWindowedAggregation.cpp | 4 ++ 9 files changed, 67 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9dcaa97099..c67d32c34d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,6 +239,13 @@ endif () add_custom_target(build_all_plugins) +# Declared here so add_compile_definitions reaches all sibling nes-* targets. +# nes-plugins/CMakeLists.txt re-declares the same option (no-op when cached). +option(NES_ENABLE_MEOS "Enable MEOS plugin (requires libmeos installed on the system)" ON) +if(NES_ENABLE_MEOS) + add_compile_definitions(NES_ENABLE_MEOS) +endif() + # Add target for common lib, which contains a minimal set # of shared functionality used by all components of nes file(GLOB NES_DIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "nes-*") diff --git a/flake.nix b/flake.nix index 2d9788a4de..026e310022 100644 --- a/flake.nix +++ b/flake.nix @@ -54,6 +54,8 @@ tbb python3 openjdk21 + paho-mqtt-c + paho-mqtt-cpp ]) ++ [ follyPkg antlr4Pkg ]; antlr4Jar = pkgs.fetchurl { @@ -244,6 +246,7 @@ "-DNES_ENABLES_TESTS=ON" "-DCMAKE_MODULE_PATH=${libdwarfModule}/share/cmake/Modules" "-DANTLR4_JAR_LOCATION=${antlr4Jar}" + "-DNES_ENABLE_MEOS=OFF" ]; enableParallelBuilding = true; @@ -347,6 +350,7 @@ "-DLLVM_DIR=${commonCmakeEnv.LLVM_DIR}" "-DANTLR4_JAR_LOCATION=${antlr4Jar}" "-DCMAKE_MODULE_PATH=${libdwarfModule}/share/cmake/Modules" + "-DNES_ENABLE_MEOS=OFF" ]; shellHook = '' unset NES_PREBUILT_VCPKG_ROOT diff --git a/nes-physical-operators/CMakeLists.txt b/nes-physical-operators/CMakeLists.txt index c38afaf4db..b62a5922a9 100644 --- a/nes-physical-operators/CMakeLists.txt +++ b/nes-physical-operators/CMakeLists.txt @@ -19,7 +19,11 @@ get_source(nes-physical-operators NES_PHYSICAL_OPERATORS_SOURCE_FILES) # Add Library add_library(nes-physical-operators ${NES_PHYSICAL_OPERATORS_SOURCE_FILES}) -target_link_libraries(nes-physical-operators PUBLIC nes-sources nes-sinks nes-nautilus nes-meos) +if(NES_ENABLE_MEOS) + target_link_libraries(nes-physical-operators PUBLIC nes-sources nes-sinks nes-nautilus nes-meos) +else() + target_link_libraries(nes-physical-operators PUBLIC nes-sources nes-sinks nes-nautilus) +endif() target_include_directories(nes-physical-operators PUBLIC $ $) diff --git a/nes-physical-operators/src/Aggregation/Function/Meos/CMakeLists.txt b/nes-physical-operators/src/Aggregation/Function/Meos/CMakeLists.txt index c34e12f47e..0b107d5c2a 100644 --- a/nes-physical-operators/src/Aggregation/Function/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Aggregation/Function/Meos/CMakeLists.txt @@ -10,5 +10,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +if(NES_ENABLE_MEOS) add_plugin(TemporalSequence AggregationPhysicalFunction nes-physical-operators TemporalSequenceAggregationPhysicalFunction.cpp) add_plugin(Var AggregationPhysicalFunction nes-physical-operators VarAggregationFunction.cpp) +endif() diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 516cdce4c3..cf83ac5aad 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -10,9 +10,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +if(NES_ENABLE_MEOS) add_plugin(TemporalIntersects PhysicalFunction nes-physical-operators TemporalIntersectsPhysicalFunction.cpp) add_plugin(TemporalIntersectsGeometry PhysicalFunction nes-physical-operators TemporalIntersectsGeometryPhysicalFunction.cpp) add_plugin(TemporalAIntersectsGeometry PhysicalFunction nes-physical-operators TemporalAIntersectsGeometryPhysicalFunction.cpp) add_plugin(TemporalEContainsGeometry PhysicalFunction nes-physical-operators TemporalEContainsGeometryPhysicalFunction.cpp) add_plugin(TemporalEDWithinGeometry PhysicalFunction nes-physical-operators TemporalEDWithinGeometryPhysicalFunction.cpp) add_plugin(TemporalAtStBox PhysicalFunction nes-physical-operators TemporalAtStBoxPhysicalFunction.cpp) +endif() diff --git a/nes-plugins/CMakeLists.txt b/nes-plugins/CMakeLists.txt index e666dd616e..3d33385853 100644 --- a/nes-plugins/CMakeLists.txt +++ b/nes-plugins/CMakeLists.txt @@ -20,33 +20,36 @@ activate_optional_plugin("Sources/TCPSource" ON) # Enable the Generator source plugin; required by systests and repl tests activate_optional_plugin("Sources/GeneratorSource" ON) activate_optional_plugin("Sinks/VoidSink" ON) -activate_optional_plugin("Sources/MQTTSource" ON) -activate_optional_plugin("Sinks/MQTTSink" ON) - -# MEOS is a dependency -activate_optional_plugin("MEOS" ON) -message(STATUS "Enable MEOS Plugin") - -# Detect the platform -if (APPLE) - message(STATUS "Building on macOS") - # Set the include and library directories for Homebrew (macOS) - set(MEOS_INCLUDE_DIR "/opt/homebrew/include" CACHE PATH "Path to MEOS include directory") - set(MEOS_PLUGIN_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" CACHE PATH "Path to MEOS plugin include directory") - include_directories(SYSTEM ${MEOS_INCLUDE_DIR} ${MEOS_PLUGIN_INCLUDE_DIR}) - include_directories(SYSTEM ${MEOS_INCLUDE_DIR} ${MEOS_PLUGIN_INCLUDE_DIR}) - link_directories(${MEOS_LIBRARY_DIR} ) - -else() - message(STATUS "Building on Linux") - - # Default behavior for Linux - find_package(meos REQUIRED) - if(meos_FOUND) - message(STATUS "MEOS found: include=${meos_INCLUDE_DIR}, library=${meos}") - include_directories(SYSTEM ${meos_INCLUDE_DIR}) +option(NES_ENABLE_MQTT "Enable MQTT source and sink plugins (requires PahoMqttCpp)" ON) +activate_optional_plugin("Sources/MQTTSource" ${NES_ENABLE_MQTT}) +activate_optional_plugin("Sinks/MQTTSink" ${NES_ENABLE_MQTT}) + +option(NES_ENABLE_MEOS "Enable MEOS plugin (requires libmeos installed on the system)" ON) +activate_optional_plugin("MEOS" ${NES_ENABLE_MEOS}) +if (NES_ENABLE_MEOS) + message(STATUS "Enable MEOS Plugin") + + # Detect the platform + if (APPLE) + message(STATUS "Building on macOS") + # Set the include and library directories for Homebrew (macOS) + set(MEOS_INCLUDE_DIR "/opt/homebrew/include" CACHE PATH "Path to MEOS include directory") + set(MEOS_PLUGIN_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" CACHE PATH "Path to MEOS plugin include directory") + include_directories(SYSTEM ${MEOS_INCLUDE_DIR} ${MEOS_PLUGIN_INCLUDE_DIR}) + include_directories(SYSTEM ${MEOS_INCLUDE_DIR} ${MEOS_PLUGIN_INCLUDE_DIR}) + link_directories(${MEOS_LIBRARY_DIR} ) + else() - message(FATAL_ERROR "MEOS library not found") + message(STATUS "Building on Linux") + + # Default behavior for Linux + find_package(meos REQUIRED) + if(meos_FOUND) + message(STATUS "MEOS found: include=${meos_INCLUDE_DIR}, library=${meos}") + include_directories(SYSTEM ${meos_INCLUDE_DIR}) + else() + message(FATAL_ERROR "MEOS library not found") + endif() endif() endif() diff --git a/nes-plugins/Sinks/MQTTSink/CMakeLists.txt b/nes-plugins/Sinks/MQTTSink/CMakeLists.txt index 4bf42deeab..80b3122e89 100644 --- a/nes-plugins/Sinks/MQTTSink/CMakeLists.txt +++ b/nes-plugins/Sinks/MQTTSink/CMakeLists.txt @@ -23,5 +23,10 @@ target_include_directories(mqtt_sink_validation_plugin_library ) find_package(PahoMqttCpp CONFIG REQUIRED) -target_link_libraries(mqtt_sink_plugin_library PRIVATE PahoMqttCpp::paho-mqttpp3-static) -target_link_libraries(mqtt_sink_validation_plugin_library PRIVATE PahoMqttCpp::paho-mqttpp3-static) +if(TARGET PahoMqttCpp::paho-mqttpp3-static) + target_link_libraries(mqtt_sink_plugin_library PRIVATE PahoMqttCpp::paho-mqttpp3-static) + target_link_libraries(mqtt_sink_validation_plugin_library PRIVATE PahoMqttCpp::paho-mqttpp3-static) +else() + target_link_libraries(mqtt_sink_plugin_library PRIVATE PahoMqttCpp::paho-mqttpp3) + target_link_libraries(mqtt_sink_validation_plugin_library PRIVATE PahoMqttCpp::paho-mqttpp3) +endif() diff --git a/nes-plugins/Sources/MQTTSource/CMakeLists.txt b/nes-plugins/Sources/MQTTSource/CMakeLists.txt index 9f9ed0dd17..27db6702a0 100644 --- a/nes-plugins/Sources/MQTTSource/CMakeLists.txt +++ b/nes-plugins/Sources/MQTTSource/CMakeLists.txt @@ -23,5 +23,10 @@ target_include_directories(mqtt_source_validation_plugin_library ) find_package(PahoMqttCpp CONFIG REQUIRED) -target_link_libraries(mqtt_source_plugin_library PRIVATE PahoMqttCpp::paho-mqttpp3-static) -target_link_libraries(mqtt_source_validation_plugin_library PRIVATE PahoMqttCpp::paho-mqttpp3-static) +if(TARGET PahoMqttCpp::paho-mqttpp3-static) + target_link_libraries(mqtt_source_plugin_library PRIVATE PahoMqttCpp::paho-mqttpp3-static) + target_link_libraries(mqtt_source_validation_plugin_library PRIVATE PahoMqttCpp::paho-mqttpp3-static) +else() + target_link_libraries(mqtt_source_plugin_library PRIVATE PahoMqttCpp::paho-mqttpp3) + target_link_libraries(mqtt_source_validation_plugin_library PRIVATE PahoMqttCpp::paho-mqttpp3) +endif() diff --git a/nes-query-optimizer/src/RewriteRules/LowerToPhysical/LowerToPhysicalWindowedAggregation.cpp b/nes-query-optimizer/src/RewriteRules/LowerToPhysical/LowerToPhysicalWindowedAggregation.cpp index c994b91a9d..eb667c31ed 100644 --- a/nes-query-optimizer/src/RewriteRules/LowerToPhysical/LowerToPhysicalWindowedAggregation.cpp +++ b/nes-query-optimizer/src/RewriteRules/LowerToPhysical/LowerToPhysicalWindowedAggregation.cpp @@ -54,8 +54,10 @@ #include #include // Special-case lowering for TEMPORAL_SEQUENCE (multi-input) aggregation +#ifdef NES_ENABLE_MEOS #include #include +#endif namespace NES { @@ -128,6 +130,7 @@ getAggregationPhysicalFunctions(const WindowedAggregationLogicalOperator& logica const auto name = descriptor->getName(); // Custom lowering path for TEMPORAL_SEQUENCE: needs three field functions (lon, lat, ts) +#ifdef NES_ENABLE_MEOS if (name == std::string_view("TemporalSequence")) { auto tsDescriptor = std::dynamic_pointer_cast(descriptor); @@ -159,6 +162,7 @@ getAggregationPhysicalFunctions(const WindowedAggregationLogicalOperator& logica aggregationPhysicalFunctions.push_back(std::move(phys)); continue; } +#endif // Default path: use registry for single-input aggregations auto aggregationInputFunction = QueryCompilation::FunctionProvider::lowerFunction(descriptor->onField); From a23e82941b27ec8f546f7ebe1e88feffd33927c0 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Thu, 11 Jun 2026 19:43:52 +0200 Subject: [PATCH 02/86] feat(nebula): wire per-event tfloat_sin/tfloat_cos/tfloat_tan (W44) Add TFLOAT_SIN, TFLOAT_COS, TFLOAT_TAN as per-event scalar operators following the extract-marshaler pattern from W25. Each takes (value:FLOAT64, ts:UINT64), constructs a MEOS single-instant temporal via tfloat_in, applies the trig C function, and extracts the FLOAT64 result via tfloat_start_value. Logical and physical function pairs registered as NES plugins; SQL parser extended with TFLOAT_SIN/COS/TAN tokens in the functionName rule and 2-arg case blocks. --- .../Meos/TfloatCosLogicalFunction.hpp | 53 +++++++++ .../Meos/TfloatSinLogicalFunction.hpp | 53 +++++++++ .../Meos/TfloatTanLogicalFunction.hpp | 53 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../Meos/TfloatCosLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/TfloatSinLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/TfloatTanLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/TfloatCosPhysicalFunction.hpp | 42 ++++++++ .../Meos/TfloatSinPhysicalFunction.hpp | 42 ++++++++ .../Meos/TfloatTanPhysicalFunction.hpp | 42 ++++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../Meos/TfloatCosPhysicalFunction.cpp | 87 +++++++++++++++ .../Meos/TfloatSinPhysicalFunction.cpp | 87 +++++++++++++++ .../Meos/TfloatTanPhysicalFunction.cpp | 87 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 5 +- .../src/AntlrSQLQueryPlanCreator.cpp | 87 +++++++++++++++ 16 files changed, 949 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatCosLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatSinLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatTanLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatCosLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatSinLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatTanLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatCosPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatSinPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatTanPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatCosPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatSinPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatTanPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TfloatCosLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatCosLogicalFunction.hpp new file mode 100644 index 0000000000..24b170ae4a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatCosLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_cos: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_cos`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TfloatCosLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatCos"; + + TfloatCosLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TfloatSinLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatSinLogicalFunction.hpp new file mode 100644 index 0000000000..310cc68ce4 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatSinLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_sin: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_sin`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TfloatSinLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatSin"; + + TfloatSinLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TfloatTanLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatTanLogicalFunction.hpp new file mode 100644 index 0000000000..e5a4fe48a1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatTanLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_tan: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_tan`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TfloatTanLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatTan"; + + TfloatTanLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 474ba11608..afc5785b55 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -18,3 +18,6 @@ add_plugin(TemporalAIntersectsGeometry LogicalFunction nes-logical-operators Tem add_plugin(TemporalEContainsGeometry LogicalFunction nes-logical-operators TemporalEContainsGeometryLogicalFunction.cpp) add_plugin(TemporalEDWithinGeometry LogicalFunction nes-logical-operators TemporalEDWithinGeometryLogicalFunction.cpp) add_plugin(TemporalAtStBox LogicalFunction nes-logical-operators TemporalAtStBoxLogicalFunction.cpp) +add_plugin(TfloatCos LogicalFunction nes-logical-operators TfloatCosLogicalFunction.cpp) +add_plugin(TfloatSin LogicalFunction nes-logical-operators TfloatSinLogicalFunction.cpp) +add_plugin(TfloatTan LogicalFunction nes-logical-operators TfloatTanLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TfloatCosLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatCosLogicalFunction.cpp new file mode 100644 index 0000000000..eb907da9d1 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatCosLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatCosLogicalFunction::TfloatCosLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TfloatCosLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatCosLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatCosLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatCosLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TfloatCosLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatCosLogicalFunction::getType() const { return NAME; } + +bool TfloatCosLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatCosLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatCosLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatCosLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatCosLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TfloatCosLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TfloatCosLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TfloatSinLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatSinLogicalFunction.cpp new file mode 100644 index 0000000000..5c47c9dfb1 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatSinLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatSinLogicalFunction::TfloatSinLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TfloatSinLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatSinLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatSinLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatSinLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TfloatSinLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatSinLogicalFunction::getType() const { return NAME; } + +bool TfloatSinLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatSinLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatSinLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatSinLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatSinLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TfloatSinLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TfloatSinLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TfloatTanLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatTanLogicalFunction.cpp new file mode 100644 index 0000000000..6ba0768d9f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatTanLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatTanLogicalFunction::TfloatTanLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TfloatTanLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatTanLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatTanLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatTanLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TfloatTanLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatTanLogicalFunction::getType() const { return NAME; } + +bool TfloatTanLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatTanLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatTanLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatTanLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatTanLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TfloatTanLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TfloatTanLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatCosPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatCosPhysicalFunction.hpp new file mode 100644 index 0000000000..34d43117b7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatCosPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_cos`. + * + * Per-event tfloat_cos: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatCosPhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatCosPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatSinPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatSinPhysicalFunction.hpp new file mode 100644 index 0000000000..5e682a44fc --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatSinPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_sin`. + * + * Per-event tfloat_sin: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatSinPhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatSinPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatTanPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatTanPhysicalFunction.hpp new file mode 100644 index 0000000000..0af2a0d03c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatTanPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_tan`. + * + * Per-event tfloat_tan: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatTanPhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatTanPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index cf83ac5aad..b6c45ca0c6 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -17,4 +17,7 @@ add_plugin(TemporalAIntersectsGeometry PhysicalFunction nes-physical-operators T add_plugin(TemporalEContainsGeometry PhysicalFunction nes-physical-operators TemporalEContainsGeometryPhysicalFunction.cpp) add_plugin(TemporalEDWithinGeometry PhysicalFunction nes-physical-operators TemporalEDWithinGeometryPhysicalFunction.cpp) add_plugin(TemporalAtStBox PhysicalFunction nes-physical-operators TemporalAtStBoxPhysicalFunction.cpp) +add_plugin(TfloatCos PhysicalFunction nes-physical-operators TfloatCosPhysicalFunction.cpp) +add_plugin(TfloatSin PhysicalFunction nes-physical-operators TfloatSinPhysicalFunction.cpp) +add_plugin(TfloatTan PhysicalFunction nes-physical-operators TfloatTanPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TfloatCosPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatCosPhysicalFunction.cpp new file mode 100644 index 0000000000..0094b419db --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatCosPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatCosPhysicalFunction::TfloatCosPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TfloatCosPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_cos(temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatCosPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TfloatCosPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TfloatCosPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TfloatSinPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatSinPhysicalFunction.cpp new file mode 100644 index 0000000000..de62924a86 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatSinPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatSinPhysicalFunction::TfloatSinPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TfloatSinPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_sin(temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatSinPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TfloatSinPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TfloatSinPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TfloatTanPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatTanPhysicalFunction.cpp new file mode 100644 index 0000000000..0111ebc7ce --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatTanPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatTanPhysicalFunction::TfloatTanPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TfloatTanPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_tan(temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatTanPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TfloatTanPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TfloatTanPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 256726e087..9e6c7cdb13 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | TFLOAT_COS | TFLOAT_SIN | TFLOAT_TAN; sinkClause: INTO sink (',' sink)*; @@ -488,6 +488,9 @@ TEMPORAL_AINTERSECTS_GEOMETRY: 'TEMPORAL_AINTERSECTS_GEOMETRY' | 'temporal_ainte TEMPORAL_ECONTAINS_GEOMETRY: 'TEMPORAL_ECONTAINS_GEOMETRY' | 'temporal_econtains_geometry'; EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; TGEO_AT_STBOX: 'TGEO_AT_STBOX' | 'tgeo_at_stbox'; +TFLOAT_COS: 'TFLOAT_COS' | 'tfloat_cos'; +TFLOAT_SIN: 'TFLOAT_SIN' | 'tfloat_sin'; +TFLOAT_TAN: 'TFLOAT_TAN' | 'tfloat_tan'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 4e9f1d7642..e3a39cb9ba 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -69,6 +69,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -1187,6 +1190,90 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont TemporalAtStBoxLogicalFunction(lonFunction, latFunction, timestampFunction, stboxFunction, borderFlag)); } break; + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_COS */ + case AntlrSQLLexer::TFLOAT_COS: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TFLOAT_COS requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatCosLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_COS */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_SIN */ + case AntlrSQLLexer::TFLOAT_SIN: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TFLOAT_SIN requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatSinLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_SIN */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_TAN */ + case AntlrSQLLexer::TFLOAT_TAN: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TFLOAT_TAN requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatTanLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_TAN */ default: /// Check if the function is a constructor for a datatype From be23758e7d19e850366a54086bc5f09f39aee48d Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 00:24:55 +0200 Subject: [PATCH 03/86] feat(nebula): wire per-event tfloat_ceil/floor/radians/degrees (W45) Add TFLOAT_CEIL, TFLOAT_FLOOR, TFLOAT_RADIANS, TFLOAT_DEGREES as per-event scalar operators following the extract-marshaler pattern from W44. Each takes (value:FLOAT64, ts:UINT64), constructs a MEOS single-instant temporal via tfloat_in, applies the scalar C function, and extracts the FLOAT64 result via tfloat_start_value. TFLOAT_DEGREES hardcodes normalize=false. Logical and physical function pairs registered as NES plugins; SQL parser extended with TFLOAT_CEIL/FLOOR/RADIANS/DEGREES tokens in the functionName rule and 2-arg case blocks. --- .../Meos/TfloatCeilLogicalFunction.hpp | 53 ++++++++ .../Meos/TfloatDegreesLogicalFunction.hpp | 53 ++++++++ .../Meos/TfloatFloorLogicalFunction.hpp | 53 ++++++++ .../Meos/TfloatRadiansLogicalFunction.hpp | 53 ++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/TfloatCeilLogicalFunction.cpp | 102 +++++++++++++++ .../Meos/TfloatDegreesLogicalFunction.cpp | 102 +++++++++++++++ .../Meos/TfloatFloorLogicalFunction.cpp | 102 +++++++++++++++ .../Meos/TfloatRadiansLogicalFunction.cpp | 102 +++++++++++++++ .../Meos/TfloatCeilPhysicalFunction.hpp | 42 +++++++ .../Meos/TfloatDegreesPhysicalFunction.hpp | 42 +++++++ .../Meos/TfloatFloorPhysicalFunction.hpp | 42 +++++++ .../Meos/TfloatRadiansPhysicalFunction.hpp | 42 +++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/TfloatCeilPhysicalFunction.cpp | 87 +++++++++++++ .../Meos/TfloatDegreesPhysicalFunction.cpp | 87 +++++++++++++ .../Meos/TfloatFloorPhysicalFunction.cpp | 87 +++++++++++++ .../Meos/TfloatRadiansPhysicalFunction.cpp | 87 +++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 116 ++++++++++++++++++ 20 files changed, 1265 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatCeilLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatDegreesLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatFloorLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatRadiansLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatCeilLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatDegreesLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatFloorLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatRadiansLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatCeilPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatDegreesPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatFloorPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatRadiansPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatCeilPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatDegreesPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatFloorPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatRadiansPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TfloatCeilLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatCeilLogicalFunction.hpp new file mode 100644 index 0000000000..e731cb516a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatCeilLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_ceil: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_ceil`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TfloatCeilLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatCeil"; + + TfloatCeilLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TfloatDegreesLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatDegreesLogicalFunction.hpp new file mode 100644 index 0000000000..80b70008c3 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatDegreesLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_degrees: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_degrees` (normalize=false). Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TfloatDegreesLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatDegrees"; + + TfloatDegreesLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TfloatFloorLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatFloorLogicalFunction.hpp new file mode 100644 index 0000000000..8734d8a205 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatFloorLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_floor: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_floor`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TfloatFloorLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatFloor"; + + TfloatFloorLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TfloatRadiansLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatRadiansLogicalFunction.hpp new file mode 100644 index 0000000000..cc5271f409 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatRadiansLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_radians: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_radians`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TfloatRadiansLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatRadians"; + + TfloatRadiansLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index afc5785b55..42cd5a93f8 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -18,6 +18,10 @@ add_plugin(TemporalAIntersectsGeometry LogicalFunction nes-logical-operators Tem add_plugin(TemporalEContainsGeometry LogicalFunction nes-logical-operators TemporalEContainsGeometryLogicalFunction.cpp) add_plugin(TemporalEDWithinGeometry LogicalFunction nes-logical-operators TemporalEDWithinGeometryLogicalFunction.cpp) add_plugin(TemporalAtStBox LogicalFunction nes-logical-operators TemporalAtStBoxLogicalFunction.cpp) +add_plugin(TfloatCeil LogicalFunction nes-logical-operators TfloatCeilLogicalFunction.cpp) add_plugin(TfloatCos LogicalFunction nes-logical-operators TfloatCosLogicalFunction.cpp) +add_plugin(TfloatDegrees LogicalFunction nes-logical-operators TfloatDegreesLogicalFunction.cpp) +add_plugin(TfloatFloor LogicalFunction nes-logical-operators TfloatFloorLogicalFunction.cpp) +add_plugin(TfloatRadians LogicalFunction nes-logical-operators TfloatRadiansLogicalFunction.cpp) add_plugin(TfloatSin LogicalFunction nes-logical-operators TfloatSinLogicalFunction.cpp) add_plugin(TfloatTan LogicalFunction nes-logical-operators TfloatTanLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TfloatCeilLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatCeilLogicalFunction.cpp new file mode 100644 index 0000000000..79c19c517a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatCeilLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatCeilLogicalFunction::TfloatCeilLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TfloatCeilLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatCeilLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatCeilLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatCeilLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TfloatCeilLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatCeilLogicalFunction::getType() const { return NAME; } + +bool TfloatCeilLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatCeilLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatCeilLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatCeilLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatCeilLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TfloatCeilLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TfloatCeilLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TfloatDegreesLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatDegreesLogicalFunction.cpp new file mode 100644 index 0000000000..d7ecfd0f63 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatDegreesLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatDegreesLogicalFunction::TfloatDegreesLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TfloatDegreesLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatDegreesLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatDegreesLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatDegreesLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TfloatDegreesLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatDegreesLogicalFunction::getType() const { return NAME; } + +bool TfloatDegreesLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatDegreesLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatDegreesLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatDegreesLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatDegreesLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TfloatDegreesLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TfloatDegreesLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TfloatFloorLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatFloorLogicalFunction.cpp new file mode 100644 index 0000000000..3c9196c92e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatFloorLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatFloorLogicalFunction::TfloatFloorLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TfloatFloorLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatFloorLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatFloorLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatFloorLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TfloatFloorLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatFloorLogicalFunction::getType() const { return NAME; } + +bool TfloatFloorLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatFloorLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatFloorLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatFloorLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatFloorLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TfloatFloorLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TfloatFloorLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TfloatRadiansLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatRadiansLogicalFunction.cpp new file mode 100644 index 0000000000..fff28b7bca --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatRadiansLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatRadiansLogicalFunction::TfloatRadiansLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TfloatRadiansLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatRadiansLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatRadiansLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatRadiansLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TfloatRadiansLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatRadiansLogicalFunction::getType() const { return NAME; } + +bool TfloatRadiansLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatRadiansLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatRadiansLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatRadiansLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatRadiansLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TfloatRadiansLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TfloatRadiansLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatCeilPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatCeilPhysicalFunction.hpp new file mode 100644 index 0000000000..984628086f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatCeilPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_ceil`. + * + * Per-event tfloat_ceil: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatCeilPhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatCeilPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatDegreesPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatDegreesPhysicalFunction.hpp new file mode 100644 index 0000000000..261eb72f71 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatDegreesPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_degrees`. + * + * Per-event tfloat_degrees (normalize=false): single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatDegreesPhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatDegreesPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatFloorPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatFloorPhysicalFunction.hpp new file mode 100644 index 0000000000..0e557615a4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatFloorPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_floor`. + * + * Per-event tfloat_floor: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatFloorPhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatFloorPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatRadiansPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatRadiansPhysicalFunction.hpp new file mode 100644 index 0000000000..35d25c6f0b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatRadiansPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_radians`. + * + * Per-event tfloat_radians: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatRadiansPhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatRadiansPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index b6c45ca0c6..01078c3d7e 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -17,7 +17,11 @@ add_plugin(TemporalAIntersectsGeometry PhysicalFunction nes-physical-operators T add_plugin(TemporalEContainsGeometry PhysicalFunction nes-physical-operators TemporalEContainsGeometryPhysicalFunction.cpp) add_plugin(TemporalEDWithinGeometry PhysicalFunction nes-physical-operators TemporalEDWithinGeometryPhysicalFunction.cpp) add_plugin(TemporalAtStBox PhysicalFunction nes-physical-operators TemporalAtStBoxPhysicalFunction.cpp) +add_plugin(TfloatCeil PhysicalFunction nes-physical-operators TfloatCeilPhysicalFunction.cpp) add_plugin(TfloatCos PhysicalFunction nes-physical-operators TfloatCosPhysicalFunction.cpp) +add_plugin(TfloatDegrees PhysicalFunction nes-physical-operators TfloatDegreesPhysicalFunction.cpp) +add_plugin(TfloatFloor PhysicalFunction nes-physical-operators TfloatFloorPhysicalFunction.cpp) +add_plugin(TfloatRadians PhysicalFunction nes-physical-operators TfloatRadiansPhysicalFunction.cpp) add_plugin(TfloatSin PhysicalFunction nes-physical-operators TfloatSinPhysicalFunction.cpp) add_plugin(TfloatTan PhysicalFunction nes-physical-operators TfloatTanPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TfloatCeilPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatCeilPhysicalFunction.cpp new file mode 100644 index 0000000000..bb3c5d6d7b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatCeilPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatCeilPhysicalFunction::TfloatCeilPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TfloatCeilPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_ceil(temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatCeilPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TfloatCeilPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TfloatCeilPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TfloatDegreesPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatDegreesPhysicalFunction.cpp new file mode 100644 index 0000000000..30871136e7 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatDegreesPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatDegreesPhysicalFunction::TfloatDegreesPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TfloatDegreesPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_degrees(temp, false); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatDegreesPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TfloatDegreesPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TfloatDegreesPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TfloatFloorPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatFloorPhysicalFunction.cpp new file mode 100644 index 0000000000..3a3ba34521 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatFloorPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatFloorPhysicalFunction::TfloatFloorPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TfloatFloorPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_floor(temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatFloorPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TfloatFloorPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TfloatFloorPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TfloatRadiansPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatRadiansPhysicalFunction.cpp new file mode 100644 index 0000000000..7988802ffb --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatRadiansPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatRadiansPhysicalFunction::TfloatRadiansPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TfloatRadiansPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_radians(temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatRadiansPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TfloatRadiansPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TfloatRadiansPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 9e6c7cdb13..27c7a40be8 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | TFLOAT_COS | TFLOAT_SIN | TFLOAT_TAN; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SIN | TFLOAT_TAN; sinkClause: INTO sink (',' sink)*; @@ -488,7 +488,11 @@ TEMPORAL_AINTERSECTS_GEOMETRY: 'TEMPORAL_AINTERSECTS_GEOMETRY' | 'temporal_ainte TEMPORAL_ECONTAINS_GEOMETRY: 'TEMPORAL_ECONTAINS_GEOMETRY' | 'temporal_econtains_geometry'; EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; TGEO_AT_STBOX: 'TGEO_AT_STBOX' | 'tgeo_at_stbox'; +TFLOAT_CEIL: 'TFLOAT_CEIL' | 'tfloat_ceil'; TFLOAT_COS: 'TFLOAT_COS' | 'tfloat_cos'; +TFLOAT_DEGREES: 'TFLOAT_DEGREES' | 'tfloat_degrees'; +TFLOAT_FLOOR: 'TFLOAT_FLOOR' | 'tfloat_floor'; +TFLOAT_RADIANS: 'TFLOAT_RADIANS' | 'tfloat_radians'; TFLOAT_SIN: 'TFLOAT_SIN' | 'tfloat_sin'; TFLOAT_TAN: 'TFLOAT_TAN' | 'tfloat_tan'; WATERMARK: 'WATERMARK' | 'watermark'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index e3a39cb9ba..48405d5879 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -69,7 +69,11 @@ #include #include #include +#include #include +#include +#include +#include #include #include #include @@ -1274,6 +1278,118 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TFLOAT_TAN */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_CEIL */ + case AntlrSQLLexer::TFLOAT_CEIL: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TFLOAT_CEIL requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatCeilLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_CEIL */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_DEGREES */ + case AntlrSQLLexer::TFLOAT_DEGREES: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TFLOAT_DEGREES requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatDegreesLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_DEGREES */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_FLOOR */ + case AntlrSQLLexer::TFLOAT_FLOOR: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TFLOAT_FLOOR requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatFloorLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_FLOOR */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_RADIANS */ + case AntlrSQLLexer::TFLOAT_RADIANS: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TFLOAT_RADIANS requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatRadiansLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_RADIANS */ default: /// Check if the function is a constructor for a datatype From 384c4c3d8c79e3c6853237cd61b1dec3f00b16c3 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 05:22:56 +0200 Subject: [PATCH 04/86] feat(nebula): wire per-event tfloat_shift_value/scale_value (W46) Add TFLOAT_SHIFT_VALUE and TFLOAT_SCALE_VALUE as per-event scalar operators following the extract-marshaler pattern. Each takes (value:FLOAT64, ts:UINT64, param:FLOAT64), constructs a MEOS single-instant temporal via tfloat_in, applies the shift or scale, and extracts the FLOAT64 result via tfloat_start_value. Logical and physical function pairs registered as NES plugins; SQL parser extended with TFLOAT_SHIFT_VALUE/SCALE_VALUE tokens in the functionName rule and 3-arg case blocks. --- .../Meos/TfloatScaleValueLogicalFunction.hpp | 54 +++++++++ .../Meos/TfloatShiftValueLogicalFunction.hpp | 54 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../Meos/TfloatScaleValueLogicalFunction.cpp | 105 ++++++++++++++++++ .../Meos/TfloatShiftValueLogicalFunction.cpp | 105 ++++++++++++++++++ .../Meos/TfloatScaleValuePhysicalFunction.hpp | 44 ++++++++ .../Meos/TfloatShiftValuePhysicalFunction.hpp | 44 ++++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../Meos/TfloatScaleValuePhysicalFunction.cpp | 91 +++++++++++++++ .../Meos/TfloatShiftValuePhysicalFunction.cpp | 91 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 4 +- .../src/AntlrSQLQueryPlanCreator.cpp | 60 ++++++++++ 12 files changed, 655 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatScaleValueLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatShiftValueLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatScaleValueLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatShiftValueLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatScaleValuePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatShiftValuePhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatScaleValuePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatShiftValuePhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TfloatScaleValueLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatScaleValueLogicalFunction.hpp new file mode 100644 index 0000000000..ad47c78148 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatScaleValueLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_scale_value: scales the value of a single-instant tfloat by a width. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_scale_value`. Takes (value:FLOAT64, ts:UINT64, width:FLOAT64), + * constructs a single-instant temporal, applies the scale, and returns FLOAT64. + */ +class TfloatScaleValueLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatScaleValue"; + + TfloatScaleValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction width); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TfloatShiftValueLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatShiftValueLogicalFunction.hpp new file mode 100644 index 0000000000..7d721d6c1b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatShiftValueLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_shift_value: shifts the value of a single-instant tfloat by a scalar. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_shift_value`. Takes (value:FLOAT64, ts:UINT64, shift:FLOAT64), + * constructs a single-instant temporal, applies the shift, and returns FLOAT64. + */ +class TfloatShiftValueLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatShiftValue"; + + TfloatShiftValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction shift); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 42cd5a93f8..6b1d4b92fa 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -23,5 +23,7 @@ add_plugin(TfloatCos LogicalFunction nes-logical-operators TfloatCosLogicalFunct add_plugin(TfloatDegrees LogicalFunction nes-logical-operators TfloatDegreesLogicalFunction.cpp) add_plugin(TfloatFloor LogicalFunction nes-logical-operators TfloatFloorLogicalFunction.cpp) add_plugin(TfloatRadians LogicalFunction nes-logical-operators TfloatRadiansLogicalFunction.cpp) +add_plugin(TfloatScaleValue LogicalFunction nes-logical-operators TfloatScaleValueLogicalFunction.cpp) +add_plugin(TfloatShiftValue LogicalFunction nes-logical-operators TfloatShiftValueLogicalFunction.cpp) add_plugin(TfloatSin LogicalFunction nes-logical-operators TfloatSinLogicalFunction.cpp) add_plugin(TfloatTan LogicalFunction nes-logical-operators TfloatTanLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TfloatScaleValueLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatScaleValueLogicalFunction.cpp new file mode 100644 index 0000000000..7631f17ea6 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatScaleValueLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatScaleValueLogicalFunction::TfloatScaleValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction width) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(width)); +} + +DataType TfloatScaleValueLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatScaleValueLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatScaleValueLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatScaleValueLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TfloatScaleValueLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatScaleValueLogicalFunction::getType() const { return NAME; } + +bool TfloatScaleValueLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatScaleValueLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatScaleValueLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatScaleValueLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatScaleValueLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TfloatScaleValueLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TfloatScaleValueLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TfloatShiftValueLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatShiftValueLogicalFunction.cpp new file mode 100644 index 0000000000..d4c4cea5de --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatShiftValueLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatShiftValueLogicalFunction::TfloatShiftValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction shift) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(shift)); +} + +DataType TfloatShiftValueLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatShiftValueLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatShiftValueLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatShiftValueLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TfloatShiftValueLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatShiftValueLogicalFunction::getType() const { return NAME; } + +bool TfloatShiftValueLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatShiftValueLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatShiftValueLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatShiftValueLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatShiftValueLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TfloatShiftValueLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TfloatShiftValueLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatScaleValuePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatScaleValuePhysicalFunction.hpp new file mode 100644 index 0000000000..776ae3e08b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatScaleValuePhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_scale_value`. + * + * Per-event tfloat_scale_value: scales a single-instant tfloat by a width, value extracted -> double. + * Takes (value:FLOAT64, ts:UINT64, width:FLOAT64). + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatScaleValuePhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatScaleValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction widthFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatShiftValuePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatShiftValuePhysicalFunction.hpp new file mode 100644 index 0000000000..f8cc2632b2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatShiftValuePhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_shift_value`. + * + * Per-event tfloat_shift_value: shifts a single-instant tfloat by a scalar, value extracted -> double. + * Takes (value:FLOAT64, ts:UINT64, shift:FLOAT64). + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatShiftValuePhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatShiftValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction shiftFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 01078c3d7e..d62de9237e 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -22,6 +22,8 @@ add_plugin(TfloatCos PhysicalFunction nes-physical-operators TfloatCosPhysicalFu add_plugin(TfloatDegrees PhysicalFunction nes-physical-operators TfloatDegreesPhysicalFunction.cpp) add_plugin(TfloatFloor PhysicalFunction nes-physical-operators TfloatFloorPhysicalFunction.cpp) add_plugin(TfloatRadians PhysicalFunction nes-physical-operators TfloatRadiansPhysicalFunction.cpp) +add_plugin(TfloatScaleValue PhysicalFunction nes-physical-operators TfloatScaleValuePhysicalFunction.cpp) +add_plugin(TfloatShiftValue PhysicalFunction nes-physical-operators TfloatShiftValuePhysicalFunction.cpp) add_plugin(TfloatSin PhysicalFunction nes-physical-operators TfloatSinPhysicalFunction.cpp) add_plugin(TfloatTan PhysicalFunction nes-physical-operators TfloatTanPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TfloatScaleValuePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatScaleValuePhysicalFunction.cpp new file mode 100644 index 0000000000..ddf3cb4de1 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatScaleValuePhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatScaleValuePhysicalFunction::TfloatScaleValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction widthFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(widthFunction)); +} + +VarVal TfloatScaleValuePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto width = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double width) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_scale_value(temp, width); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, width); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatScaleValuePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TfloatScaleValuePhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TfloatScaleValuePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TfloatShiftValuePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatShiftValuePhysicalFunction.cpp new file mode 100644 index 0000000000..3f5de19d9f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatShiftValuePhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatShiftValuePhysicalFunction::TfloatShiftValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction shiftFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(shiftFunction)); +} + +VarVal TfloatShiftValuePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto shift = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double shift) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_shift_value(temp, shift); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, shift); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatShiftValuePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TfloatShiftValuePhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TfloatShiftValuePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 27c7a40be8..8f7b599c8e 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SIN | TFLOAT_TAN; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN; sinkClause: INTO sink (',' sink)*; @@ -493,6 +493,8 @@ TFLOAT_COS: 'TFLOAT_COS' | 'tfloat_cos'; TFLOAT_DEGREES: 'TFLOAT_DEGREES' | 'tfloat_degrees'; TFLOAT_FLOOR: 'TFLOAT_FLOOR' | 'tfloat_floor'; TFLOAT_RADIANS: 'TFLOAT_RADIANS' | 'tfloat_radians'; +TFLOAT_SCALE_VALUE: 'TFLOAT_SCALE_VALUE' | 'tfloat_scale_value'; +TFLOAT_SHIFT_VALUE: 'TFLOAT_SHIFT_VALUE' | 'tfloat_shift_value'; TFLOAT_SIN: 'TFLOAT_SIN' | 'tfloat_sin'; TFLOAT_TAN: 'TFLOAT_TAN' | 'tfloat_tan'; WATERMARK: 'WATERMARK' | 'watermark'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 48405d5879..ef6e63e327 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -74,6 +74,8 @@ #include #include #include +#include +#include #include #include #include @@ -1390,6 +1392,64 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TFLOAT_RADIANS */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_SCALE_VALUE */ + case AntlrSQLLexer::TFLOAT_SCALE_VALUE: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TFLOAT_SCALE_VALUE requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatScaleValueLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_SCALE_VALUE */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_SHIFT_VALUE */ + case AntlrSQLLexer::TFLOAT_SHIFT_VALUE: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TFLOAT_SHIFT_VALUE requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatShiftValueLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_SHIFT_VALUE */ default: /// Check if the function is a constructor for a datatype From 02ee1160ca170b0736e98eed048d205bb8bd2762 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 05:29:41 +0200 Subject: [PATCH 05/86] feat(meos): add TNUMBER_ABS and TFLOAT_SHIFT_SCALE_VALUE NES operators (W47) Adds per-event NES operators backed by `tnumber_abs` (2-arg: value, ts) and `tfloat_shift_scale_value` (4-arg: value, ts, shift, width). Each operator constructs a single-instant tfloat, applies the MEOS function, and returns the resulting double. Logical/physical function pairs, plugin registrations, grammar tokens, and parser case blocks are included. --- .../TfloatShiftScaleValueLogicalFunction.hpp | 55 +++++++++ .../Meos/TnumberAbsLogicalFunction.hpp | 53 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../TfloatShiftScaleValueLogicalFunction.cpp | 108 ++++++++++++++++++ .../Meos/TnumberAbsLogicalFunction.cpp | 102 +++++++++++++++++ .../TfloatShiftScaleValuePhysicalFunction.hpp | 44 +++++++ .../Meos/TnumberAbsPhysicalFunction.hpp | 42 +++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../TfloatShiftScaleValuePhysicalFunction.cpp | 95 +++++++++++++++ .../Meos/TnumberAbsPhysicalFunction.cpp | 87 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 4 +- .../src/AntlrSQLQueryPlanCreator.cpp | 60 ++++++++++ 12 files changed, 653 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatShiftScaleValueLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TnumberAbsLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatShiftScaleValueLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TnumberAbsLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatShiftScaleValuePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TnumberAbsPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatShiftScaleValuePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TnumberAbsPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TfloatShiftScaleValueLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatShiftScaleValueLogicalFunction.hpp new file mode 100644 index 0000000000..b4c2b90990 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatShiftScaleValueLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_shift_scale_value: shifts and scales a single-instant tfloat by shift and width. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_shift_scale_value`. Takes (value:FLOAT64, ts:UINT64, shift:FLOAT64, width:FLOAT64), + * constructs a single-instant temporal, applies shift+scale, and returns FLOAT64. + */ +class TfloatShiftScaleValueLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatShiftScaleValue"; + + TfloatShiftScaleValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction shift, + LogicalFunction width); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TnumberAbsLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TnumberAbsLogicalFunction.hpp new file mode 100644 index 0000000000..6fe10d29d1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TnumberAbsLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tnumber_abs: single-instant tnumber transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tnumber_abs`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TnumberAbsLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TnumberAbs"; + + TnumberAbsLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 6b1d4b92fa..01154d9eee 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -24,6 +24,8 @@ add_plugin(TfloatDegrees LogicalFunction nes-logical-operators TfloatDegreesLogi add_plugin(TfloatFloor LogicalFunction nes-logical-operators TfloatFloorLogicalFunction.cpp) add_plugin(TfloatRadians LogicalFunction nes-logical-operators TfloatRadiansLogicalFunction.cpp) add_plugin(TfloatScaleValue LogicalFunction nes-logical-operators TfloatScaleValueLogicalFunction.cpp) +add_plugin(TfloatShiftScaleValue LogicalFunction nes-logical-operators TfloatShiftScaleValueLogicalFunction.cpp) add_plugin(TfloatShiftValue LogicalFunction nes-logical-operators TfloatShiftValueLogicalFunction.cpp) add_plugin(TfloatSin LogicalFunction nes-logical-operators TfloatSinLogicalFunction.cpp) add_plugin(TfloatTan LogicalFunction nes-logical-operators TfloatTanLogicalFunction.cpp) +add_plugin(TnumberAbs LogicalFunction nes-logical-operators TnumberAbsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TfloatShiftScaleValueLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatShiftScaleValueLogicalFunction.cpp new file mode 100644 index 0000000000..ef6f4c2a71 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatShiftScaleValueLogicalFunction.cpp @@ -0,0 +1,108 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatShiftScaleValueLogicalFunction::TfloatShiftScaleValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction shift, + LogicalFunction width) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(shift)); + parameters.push_back(std::move(width)); +} + +DataType TfloatShiftScaleValueLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatShiftScaleValueLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatShiftScaleValueLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatShiftScaleValueLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TfloatShiftScaleValueLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatShiftScaleValueLogicalFunction::getType() const { return NAME; } + +bool TfloatShiftScaleValueLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatShiftScaleValueLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatShiftScaleValueLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatShiftScaleValueLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatShiftScaleValueLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TfloatShiftScaleValueLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TfloatShiftScaleValueLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TnumberAbsLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TnumberAbsLogicalFunction.cpp new file mode 100644 index 0000000000..5b67053833 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TnumberAbsLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TnumberAbsLogicalFunction::TnumberAbsLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TnumberAbsLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TnumberAbsLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TnumberAbsLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TnumberAbsLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TnumberAbsLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TnumberAbsLogicalFunction::getType() const { return NAME; } + +bool TnumberAbsLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TnumberAbsLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TnumberAbsLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TnumberAbsLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTnumberAbsLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TnumberAbsLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TnumberAbsLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatShiftScaleValuePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatShiftScaleValuePhysicalFunction.hpp new file mode 100644 index 0000000000..efdb1e1c98 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatShiftScaleValuePhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_shift_scale_value`. + * + * Per-event tfloat_shift_scale_value: shifts and scales a single-instant tfloat. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatShiftScaleValuePhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatShiftScaleValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction shiftFunction, + PhysicalFunction widthFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TnumberAbsPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TnumberAbsPhysicalFunction.hpp new file mode 100644 index 0000000000..9c1c46c10d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TnumberAbsPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tnumber_abs`. + * + * Per-event tnumber_abs: single-instant tnumber transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TnumberAbsPhysicalFunction : public PhysicalFunctionConcept { +public: + TnumberAbsPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index d62de9237e..ad801dc314 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -23,7 +23,9 @@ add_plugin(TfloatDegrees PhysicalFunction nes-physical-operators TfloatDegreesPh add_plugin(TfloatFloor PhysicalFunction nes-physical-operators TfloatFloorPhysicalFunction.cpp) add_plugin(TfloatRadians PhysicalFunction nes-physical-operators TfloatRadiansPhysicalFunction.cpp) add_plugin(TfloatScaleValue PhysicalFunction nes-physical-operators TfloatScaleValuePhysicalFunction.cpp) +add_plugin(TfloatShiftScaleValue PhysicalFunction nes-physical-operators TfloatShiftScaleValuePhysicalFunction.cpp) add_plugin(TfloatShiftValue PhysicalFunction nes-physical-operators TfloatShiftValuePhysicalFunction.cpp) add_plugin(TfloatSin PhysicalFunction nes-physical-operators TfloatSinPhysicalFunction.cpp) add_plugin(TfloatTan PhysicalFunction nes-physical-operators TfloatTanPhysicalFunction.cpp) +add_plugin(TnumberAbs PhysicalFunction nes-physical-operators TnumberAbsPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TfloatShiftScaleValuePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatShiftScaleValuePhysicalFunction.cpp new file mode 100644 index 0000000000..7095a9c943 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatShiftScaleValuePhysicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatShiftScaleValuePhysicalFunction::TfloatShiftScaleValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction shiftFunction, + PhysicalFunction widthFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(shiftFunction)); + parameterFunctions.push_back(std::move(widthFunction)); +} + +VarVal TfloatShiftScaleValuePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto shift = parameterValues[2].cast>(); + auto width = parameterValues[3].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double shift, double width) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_shift_scale_value(temp, shift, width); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, shift, width); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatShiftScaleValuePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TfloatShiftScaleValuePhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TfloatShiftScaleValuePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TnumberAbsPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TnumberAbsPhysicalFunction.cpp new file mode 100644 index 0000000000..d61f38178c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TnumberAbsPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TnumberAbsPhysicalFunction::TnumberAbsPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TnumberAbsPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tnumber_abs(temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTnumberAbsPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TnumberAbsPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TnumberAbsPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 8f7b599c8e..eaeea079a1 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -494,9 +494,11 @@ TFLOAT_DEGREES: 'TFLOAT_DEGREES' | 'tfloat_degrees'; TFLOAT_FLOOR: 'TFLOAT_FLOOR' | 'tfloat_floor'; TFLOAT_RADIANS: 'TFLOAT_RADIANS' | 'tfloat_radians'; TFLOAT_SCALE_VALUE: 'TFLOAT_SCALE_VALUE' | 'tfloat_scale_value'; +TFLOAT_SHIFT_SCALE_VALUE: 'TFLOAT_SHIFT_SCALE_VALUE' | 'tfloat_shift_scale_value'; TFLOAT_SHIFT_VALUE: 'TFLOAT_SHIFT_VALUE' | 'tfloat_shift_value'; TFLOAT_SIN: 'TFLOAT_SIN' | 'tfloat_sin'; TFLOAT_TAN: 'TFLOAT_TAN' | 'tfloat_tan'; +TNUMBER_ABS: 'TNUMBER_ABS' | 'tnumber_abs'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index ef6e63e327..1043181e7a 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -75,9 +75,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -1450,6 +1452,64 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TFLOAT_SHIFT_VALUE */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_SHIFT_SCALE_VALUE */ + case AntlrSQLLexer::TFLOAT_SHIFT_SCALE_VALUE: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TFLOAT_SHIFT_SCALE_VALUE requires exactly 4 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a3 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatShiftScaleValueLogicalFunction(a0, a1, a2, a3)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_SHIFT_SCALE_VALUE */ + /* BEGIN CODEGEN PARSER GLUE: TNUMBER_ABS */ + case AntlrSQLLexer::TNUMBER_ABS: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TNUMBER_ABS requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TnumberAbsLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TNUMBER_ABS */ default: /// Check if the function is a constructor for a datatype From 6ff9b082e5f0e25fcf9fe48a4d54adc3fe8ee247 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 05:35:38 +0200 Subject: [PATCH 06/86] feat(meos): add ADD/SUB/MUL/DIV_TFLOAT_FLOAT NES operators (W48) Adds per-event NES operators backed by `add_tfloat_float`, `sub_tfloat_float`, `mul_tfloat_float`, and `div_tfloat_float` (3-arg each: value, ts, scalar). Each operator constructs a single-instant tfloat, applies the MEOS arithmetic function against a constant scalar, and returns the resulting double. Logical/physical function pairs, plugin registrations, grammar tokens, and parser case blocks are included. --- .../Meos/AddTfloatFloatLogicalFunction.hpp | 54 ++++++++ .../Meos/DivTfloatFloatLogicalFunction.hpp | 54 ++++++++ .../Meos/MulTfloatFloatLogicalFunction.hpp | 54 ++++++++ .../Meos/SubTfloatFloatLogicalFunction.hpp | 54 ++++++++ .../Meos/AddTfloatFloatLogicalFunction.cpp | 105 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/DivTfloatFloatLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/MulTfloatFloatLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/SubTfloatFloatLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/AddTfloatFloatPhysicalFunction.hpp | 43 +++++++ .../Meos/DivTfloatFloatPhysicalFunction.hpp | 43 +++++++ .../Meos/MulTfloatFloatPhysicalFunction.hpp | 43 +++++++ .../Meos/SubTfloatFloatPhysicalFunction.hpp | 43 +++++++ .../Meos/AddTfloatFloatPhysicalFunction.cpp | 91 +++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/DivTfloatFloatPhysicalFunction.cpp | 91 +++++++++++++ .../Meos/MulTfloatFloatPhysicalFunction.cpp | 91 +++++++++++++ .../Meos/SubTfloatFloatPhysicalFunction.cpp | 91 +++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 120 ++++++++++++++++++ 20 files changed, 1305 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AddTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/DivTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/MulTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/SubTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AddTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/DivTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/MulTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/SubTfloatFloatLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AddTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/DivTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/MulTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/SubTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AddTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/DivTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/MulTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/SubTfloatFloatPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AddTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AddTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..7fbbb663c8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AddTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event add_tfloat_float: adds a constant to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `add_tfloat_float`. Takes (value:FLOAT64, ts:UINT64, addend:FLOAT64), + * constructs a single-instant temporal, applies the addition, and returns FLOAT64. + */ +class AddTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AddTfloatFloat"; + + AddTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction addend); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/DivTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/DivTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..f028b28994 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/DivTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event div_tfloat_float: divides a single-instant tfloat value by a constant. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `div_tfloat_float`. Takes (value:FLOAT64, ts:UINT64, divisor:FLOAT64), + * constructs a single-instant temporal, applies the division, and returns FLOAT64. + */ +class DivTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "DivTfloatFloat"; + + DivTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction divisor); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/MulTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/MulTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..a2f3606cca --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/MulTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event mul_tfloat_float: multiplies a single-instant tfloat value by a constant. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `mul_tfloat_float`. Takes (value:FLOAT64, ts:UINT64, factor:FLOAT64), + * constructs a single-instant temporal, applies the multiplication, and returns FLOAT64. + */ +class MulTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "MulTfloatFloat"; + + MulTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction factor); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/SubTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/SubTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..ea5a1a9d26 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/SubTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event sub_tfloat_float: subtracts a constant from a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `sub_tfloat_float`. Takes (value:FLOAT64, ts:UINT64, subtrahend:FLOAT64), + * constructs a single-instant temporal, applies the subtraction, and returns FLOAT64. + */ +class SubTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "SubTfloatFloat"; + + SubTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction subtrahend); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AddTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AddTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..6cc26a04a5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AddTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AddTfloatFloatLogicalFunction::AddTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction addend) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(addend)); +} + +DataType AddTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AddTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AddTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AddTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AddTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AddTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool AddTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AddTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AddTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AddTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAddTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AddTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AddTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 01154d9eee..1f40833d3b 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -24,6 +24,10 @@ add_plugin(TfloatDegrees LogicalFunction nes-logical-operators TfloatDegreesLogi add_plugin(TfloatFloor LogicalFunction nes-logical-operators TfloatFloorLogicalFunction.cpp) add_plugin(TfloatRadians LogicalFunction nes-logical-operators TfloatRadiansLogicalFunction.cpp) add_plugin(TfloatScaleValue LogicalFunction nes-logical-operators TfloatScaleValueLogicalFunction.cpp) +add_plugin(AddTfloatFloat LogicalFunction nes-logical-operators AddTfloatFloatLogicalFunction.cpp) +add_plugin(DivTfloatFloat LogicalFunction nes-logical-operators DivTfloatFloatLogicalFunction.cpp) +add_plugin(MulTfloatFloat LogicalFunction nes-logical-operators MulTfloatFloatLogicalFunction.cpp) +add_plugin(SubTfloatFloat LogicalFunction nes-logical-operators SubTfloatFloatLogicalFunction.cpp) add_plugin(TfloatShiftScaleValue LogicalFunction nes-logical-operators TfloatShiftScaleValueLogicalFunction.cpp) add_plugin(TfloatShiftValue LogicalFunction nes-logical-operators TfloatShiftValueLogicalFunction.cpp) add_plugin(TfloatSin LogicalFunction nes-logical-operators TfloatSinLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/DivTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/DivTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..a9bb9268b7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/DivTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +DivTfloatFloatLogicalFunction::DivTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction divisor) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(divisor)); +} + +DataType DivTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction DivTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector DivTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction DivTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "DivTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view DivTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool DivTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string DivTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction DivTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction DivTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterDivTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "DivTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return DivTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/MulTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/MulTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..c28dba03cf --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/MulTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +MulTfloatFloatLogicalFunction::MulTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction factor) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(factor)); +} + +DataType MulTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction MulTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector MulTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction MulTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "MulTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view MulTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool MulTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string MulTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction MulTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction MulTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterMulTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "MulTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return MulTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/SubTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/SubTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..d1eda09525 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/SubTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +SubTfloatFloatLogicalFunction::SubTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction subtrahend) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(subtrahend)); +} + +DataType SubTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction SubTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector SubTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction SubTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "SubTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view SubTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool SubTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string SubTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction SubTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction SubTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterSubTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "SubTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return SubTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AddTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AddTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..599af33b95 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AddTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `add_tfloat_float`. + * + * Per-event add_tfloat_float: adds a constant to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AddTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AddTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction addendFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/DivTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/DivTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..c221eba2e9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/DivTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `div_tfloat_float`. + * + * Per-event div_tfloat_float: divides a single-instant tfloat value by a constant. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class DivTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + DivTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction divisorFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/MulTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/MulTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..5014e03f50 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/MulTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `mul_tfloat_float`. + * + * Per-event mul_tfloat_float: multiplies a single-instant tfloat value by a constant. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class MulTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + MulTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction factorFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/SubTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/SubTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..f1ed79336a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/SubTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `sub_tfloat_float`. + * + * Per-event sub_tfloat_float: subtracts a constant from a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class SubTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + SubTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction subtrahendFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AddTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AddTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..75dc0a3994 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AddTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AddTfloatFloatPhysicalFunction::AddTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction addendFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(addendFunction)); +} + +VarVal AddTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto addend = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double addend) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = add_tfloat_float(temp, addend); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, addend); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAddTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AddTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AddTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index ad801dc314..fcfbe5b9ba 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -23,6 +23,10 @@ add_plugin(TfloatDegrees PhysicalFunction nes-physical-operators TfloatDegreesPh add_plugin(TfloatFloor PhysicalFunction nes-physical-operators TfloatFloorPhysicalFunction.cpp) add_plugin(TfloatRadians PhysicalFunction nes-physical-operators TfloatRadiansPhysicalFunction.cpp) add_plugin(TfloatScaleValue PhysicalFunction nes-physical-operators TfloatScaleValuePhysicalFunction.cpp) +add_plugin(AddTfloatFloat PhysicalFunction nes-physical-operators AddTfloatFloatPhysicalFunction.cpp) +add_plugin(DivTfloatFloat PhysicalFunction nes-physical-operators DivTfloatFloatPhysicalFunction.cpp) +add_plugin(MulTfloatFloat PhysicalFunction nes-physical-operators MulTfloatFloatPhysicalFunction.cpp) +add_plugin(SubTfloatFloat PhysicalFunction nes-physical-operators SubTfloatFloatPhysicalFunction.cpp) add_plugin(TfloatShiftScaleValue PhysicalFunction nes-physical-operators TfloatShiftScaleValuePhysicalFunction.cpp) add_plugin(TfloatShiftValue PhysicalFunction nes-physical-operators TfloatShiftValuePhysicalFunction.cpp) add_plugin(TfloatSin PhysicalFunction nes-physical-operators TfloatSinPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/DivTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/DivTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..c0f7e9da02 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/DivTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +DivTfloatFloatPhysicalFunction::DivTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction divisorFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(divisorFunction)); +} + +VarVal DivTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto divisor = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double divisor) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = div_tfloat_float(temp, divisor); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, divisor); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterDivTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "DivTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return DivTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/MulTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/MulTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..80205907b6 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/MulTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +MulTfloatFloatPhysicalFunction::MulTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction factorFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(factorFunction)); +} + +VarVal MulTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto factor = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double factor) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = mul_tfloat_float(temp, factor); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, factor); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterMulTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "MulTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return MulTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/SubTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/SubTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..75e6eb5c39 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/SubTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +SubTfloatFloatPhysicalFunction::SubTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction subtrahendFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(subtrahendFunction)); +} + +VarVal SubTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto subtrahend = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double subtrahend) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = sub_tfloat_float(temp, subtrahend); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, subtrahend); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterSubTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "SubTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return SubTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index eaeea079a1..893cd4b5d3 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | DIV_TFLOAT_FLOAT | MUL_TFLOAT_FLOAT | SUB_TFLOAT_FLOAT | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -488,6 +488,10 @@ TEMPORAL_AINTERSECTS_GEOMETRY: 'TEMPORAL_AINTERSECTS_GEOMETRY' | 'temporal_ainte TEMPORAL_ECONTAINS_GEOMETRY: 'TEMPORAL_ECONTAINS_GEOMETRY' | 'temporal_econtains_geometry'; EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; TGEO_AT_STBOX: 'TGEO_AT_STBOX' | 'tgeo_at_stbox'; +ADD_TFLOAT_FLOAT: 'ADD_TFLOAT_FLOAT' | 'add_tfloat_float'; +DIV_TFLOAT_FLOAT: 'DIV_TFLOAT_FLOAT' | 'div_tfloat_float'; +MUL_TFLOAT_FLOAT: 'MUL_TFLOAT_FLOAT' | 'mul_tfloat_float'; +SUB_TFLOAT_FLOAT: 'SUB_TFLOAT_FLOAT' | 'sub_tfloat_float'; TFLOAT_CEIL: 'TFLOAT_CEIL' | 'tfloat_ceil'; TFLOAT_COS: 'TFLOAT_COS' | 'tfloat_cos'; TFLOAT_DEGREES: 'TFLOAT_DEGREES' | 'tfloat_degrees'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 1043181e7a..6fc7f008dc 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -69,6 +69,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -1510,6 +1514,122 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TNUMBER_ABS */ + /* BEGIN CODEGEN PARSER GLUE: ADD_TFLOAT_FLOAT */ + case AntlrSQLLexer::ADD_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ADD_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AddTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ADD_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: DIV_TFLOAT_FLOAT */ + case AntlrSQLLexer::DIV_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("DIV_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(DivTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: DIV_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: MUL_TFLOAT_FLOAT */ + case AntlrSQLLexer::MUL_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("MUL_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(MulTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: MUL_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: SUB_TFLOAT_FLOAT */ + case AntlrSQLLexer::SUB_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("SUB_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(SubTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: SUB_TFLOAT_FLOAT */ default: /// Check if the function is a constructor for a datatype From d376592e03840130b55e045d7733b36c5e15a53b Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 05:44:15 +0200 Subject: [PATCH 07/86] feat(meos): add ADD/SUB/MUL/DIV_TNUMBER_TNUMBER NES operators (W49) Adds per-event NES operators backed by `add_tnumber_tnumber`, `sub_tnumber_tnumber`, `mul_tnumber_tnumber`, and `div_tnumber_tnumber` (3-arg each: value1, value2, shared-ts). Each operator constructs two co-instant tfloats, applies the MEOS element-wise arithmetic function, and returns the resulting double. Logical/physical function pairs, plugin registrations, grammar tokens, and parser case blocks are included. --- .../Meos/AddTnumberTnumberLogicalFunction.hpp | 54 ++++++++ .../Meos/DivTnumberTnumberLogicalFunction.hpp | 54 ++++++++ .../Meos/MulTnumberTnumberLogicalFunction.hpp | 54 ++++++++ .../Meos/SubTnumberTnumberLogicalFunction.hpp | 54 ++++++++ .../Meos/AddTnumberTnumberLogicalFunction.cpp | 105 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/DivTnumberTnumberLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/MulTnumberTnumberLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/SubTnumberTnumberLogicalFunction.cpp | 105 +++++++++++++++ .../AddTnumberTnumberPhysicalFunction.hpp | 43 +++++++ .../DivTnumberTnumberPhysicalFunction.hpp | 43 +++++++ .../MulTnumberTnumberPhysicalFunction.hpp | 43 +++++++ .../SubTnumberTnumberPhysicalFunction.hpp | 43 +++++++ .../AddTnumberTnumberPhysicalFunction.cpp | 94 ++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../DivTnumberTnumberPhysicalFunction.cpp | 94 ++++++++++++++ .../MulTnumberTnumberPhysicalFunction.cpp | 94 ++++++++++++++ .../SubTnumberTnumberPhysicalFunction.cpp | 94 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 120 ++++++++++++++++++ 20 files changed, 1317 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AddTnumberTnumberLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/DivTnumberTnumberLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/MulTnumberTnumberLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/SubTnumberTnumberLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AddTnumberTnumberLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/DivTnumberTnumberLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/MulTnumberTnumberLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/SubTnumberTnumberLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AddTnumberTnumberPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/DivTnumberTnumberPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/MulTnumberTnumberPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/SubTnumberTnumberPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AddTnumberTnumberPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/DivTnumberTnumberPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/MulTnumberTnumberPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/SubTnumberTnumberPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AddTnumberTnumberLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AddTnumberTnumberLogicalFunction.hpp new file mode 100644 index 0000000000..eb6bf59984 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AddTnumberTnumberLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event add_tnumber_tnumber: element-wise addition of two single-instant tnumbers. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `add_tnumber_tnumber`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two co-instant temporals, applies the addition, and returns FLOAT64. + */ +class AddTnumberTnumberLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AddTnumberTnumber"; + + AddTnumberTnumberLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/DivTnumberTnumberLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/DivTnumberTnumberLogicalFunction.hpp new file mode 100644 index 0000000000..e85de51c18 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/DivTnumberTnumberLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event div_tnumber_tnumber: element-wise division of two single-instant tnumbers. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `div_tnumber_tnumber`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two co-instant temporals, applies the division, and returns FLOAT64. + */ +class DivTnumberTnumberLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "DivTnumberTnumber"; + + DivTnumberTnumberLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/MulTnumberTnumberLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/MulTnumberTnumberLogicalFunction.hpp new file mode 100644 index 0000000000..e3898c52ed --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/MulTnumberTnumberLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event mul_tnumber_tnumber: element-wise multiplication of two single-instant tnumbers. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `mul_tnumber_tnumber`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two co-instant temporals, applies the multiplication, and returns FLOAT64. + */ +class MulTnumberTnumberLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "MulTnumberTnumber"; + + MulTnumberTnumberLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/SubTnumberTnumberLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/SubTnumberTnumberLogicalFunction.hpp new file mode 100644 index 0000000000..94891a2836 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/SubTnumberTnumberLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event sub_tnumber_tnumber: element-wise subtraction of two single-instant tnumbers. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `sub_tnumber_tnumber`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two co-instant temporals, applies the subtraction, and returns FLOAT64. + */ +class SubTnumberTnumberLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "SubTnumberTnumber"; + + SubTnumberTnumberLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AddTnumberTnumberLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AddTnumberTnumberLogicalFunction.cpp new file mode 100644 index 0000000000..223f155801 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AddTnumberTnumberLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AddTnumberTnumberLogicalFunction::AddTnumberTnumberLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AddTnumberTnumberLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AddTnumberTnumberLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AddTnumberTnumberLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AddTnumberTnumberLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AddTnumberTnumberLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AddTnumberTnumberLogicalFunction::getType() const { return NAME; } + +bool AddTnumberTnumberLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AddTnumberTnumberLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AddTnumberTnumberLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AddTnumberTnumberLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAddTnumberTnumberLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AddTnumberTnumberLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AddTnumberTnumberLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 1f40833d3b..c2debfca0e 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -25,6 +25,10 @@ add_plugin(TfloatFloor LogicalFunction nes-logical-operators TfloatFloorLogicalF add_plugin(TfloatRadians LogicalFunction nes-logical-operators TfloatRadiansLogicalFunction.cpp) add_plugin(TfloatScaleValue LogicalFunction nes-logical-operators TfloatScaleValueLogicalFunction.cpp) add_plugin(AddTfloatFloat LogicalFunction nes-logical-operators AddTfloatFloatLogicalFunction.cpp) +add_plugin(AddTnumberTnumber LogicalFunction nes-logical-operators AddTnumberTnumberLogicalFunction.cpp) +add_plugin(DivTnumberTnumber LogicalFunction nes-logical-operators DivTnumberTnumberLogicalFunction.cpp) +add_plugin(MulTnumberTnumber LogicalFunction nes-logical-operators MulTnumberTnumberLogicalFunction.cpp) +add_plugin(SubTnumberTnumber LogicalFunction nes-logical-operators SubTnumberTnumberLogicalFunction.cpp) add_plugin(DivTfloatFloat LogicalFunction nes-logical-operators DivTfloatFloatLogicalFunction.cpp) add_plugin(MulTfloatFloat LogicalFunction nes-logical-operators MulTfloatFloatLogicalFunction.cpp) add_plugin(SubTfloatFloat LogicalFunction nes-logical-operators SubTfloatFloatLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/DivTnumberTnumberLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/DivTnumberTnumberLogicalFunction.cpp new file mode 100644 index 0000000000..fc7b32aa87 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/DivTnumberTnumberLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +DivTnumberTnumberLogicalFunction::DivTnumberTnumberLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType DivTnumberTnumberLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction DivTnumberTnumberLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector DivTnumberTnumberLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction DivTnumberTnumberLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "DivTnumberTnumberLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view DivTnumberTnumberLogicalFunction::getType() const { return NAME; } + +bool DivTnumberTnumberLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string DivTnumberTnumberLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction DivTnumberTnumberLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction DivTnumberTnumberLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterDivTnumberTnumberLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "DivTnumberTnumberLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return DivTnumberTnumberLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/MulTnumberTnumberLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/MulTnumberTnumberLogicalFunction.cpp new file mode 100644 index 0000000000..9d5d5fa562 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/MulTnumberTnumberLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +MulTnumberTnumberLogicalFunction::MulTnumberTnumberLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType MulTnumberTnumberLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction MulTnumberTnumberLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector MulTnumberTnumberLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction MulTnumberTnumberLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "MulTnumberTnumberLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view MulTnumberTnumberLogicalFunction::getType() const { return NAME; } + +bool MulTnumberTnumberLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string MulTnumberTnumberLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction MulTnumberTnumberLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction MulTnumberTnumberLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterMulTnumberTnumberLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "MulTnumberTnumberLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return MulTnumberTnumberLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/SubTnumberTnumberLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/SubTnumberTnumberLogicalFunction.cpp new file mode 100644 index 0000000000..844fe38ede --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/SubTnumberTnumberLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +SubTnumberTnumberLogicalFunction::SubTnumberTnumberLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType SubTnumberTnumberLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction SubTnumberTnumberLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector SubTnumberTnumberLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction SubTnumberTnumberLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "SubTnumberTnumberLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view SubTnumberTnumberLogicalFunction::getType() const { return NAME; } + +bool SubTnumberTnumberLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string SubTnumberTnumberLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction SubTnumberTnumberLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction SubTnumberTnumberLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterSubTnumberTnumberLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "SubTnumberTnumberLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return SubTnumberTnumberLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AddTnumberTnumberPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AddTnumberTnumberPhysicalFunction.hpp new file mode 100644 index 0000000000..c45dd431d3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AddTnumberTnumberPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `add_tnumber_tnumber`. + * + * Per-event element-wise addition of two co-instant tnumbers. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AddTnumberTnumberPhysicalFunction : public PhysicalFunctionConcept { +public: + AddTnumberTnumberPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/DivTnumberTnumberPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/DivTnumberTnumberPhysicalFunction.hpp new file mode 100644 index 0000000000..3fde0ad5da --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/DivTnumberTnumberPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `div_tnumber_tnumber`. + * + * Per-event element-wise division of two co-instant tnumbers. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class DivTnumberTnumberPhysicalFunction : public PhysicalFunctionConcept { +public: + DivTnumberTnumberPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/MulTnumberTnumberPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/MulTnumberTnumberPhysicalFunction.hpp new file mode 100644 index 0000000000..f3b4af1bcf --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/MulTnumberTnumberPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `mul_tnumber_tnumber`. + * + * Per-event element-wise multiplication of two co-instant tnumbers. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class MulTnumberTnumberPhysicalFunction : public PhysicalFunctionConcept { +public: + MulTnumberTnumberPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/SubTnumberTnumberPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/SubTnumberTnumberPhysicalFunction.hpp new file mode 100644 index 0000000000..8e411da16d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/SubTnumberTnumberPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `sub_tnumber_tnumber`. + * + * Per-event element-wise subtraction of two co-instant tnumbers. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class SubTnumberTnumberPhysicalFunction : public PhysicalFunctionConcept { +public: + SubTnumberTnumberPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AddTnumberTnumberPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AddTnumberTnumberPhysicalFunction.cpp new file mode 100644 index 0000000000..6f709c0ceb --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AddTnumberTnumberPhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AddTnumberTnumberPhysicalFunction::AddTnumberTnumberPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AddTnumberTnumberPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value1, double value2, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + const std::string tsStr = MEOS::Meos::convertEpochToTimestamp(ts); + std::string wkt1 = fmt::format("{}@{}", value1, tsStr); + std::string wkt2 = fmt::format("{}@{}", value2, tsStr); + Temporal* t1 = tfloat_in(wkt1.c_str()); + Temporal* t2 = tfloat_in(wkt2.c_str()); + if (!t1 || !t2) { free(t1); free(t2); return 0.0; } + Temporal* res = add_tnumber_tnumber(t1, t2); + free(t1); free(t2); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAddTnumberTnumberPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AddTnumberTnumberPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AddTnumberTnumberPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index fcfbe5b9ba..de2aeb2de3 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -24,6 +24,10 @@ add_plugin(TfloatFloor PhysicalFunction nes-physical-operators TfloatFloorPhysic add_plugin(TfloatRadians PhysicalFunction nes-physical-operators TfloatRadiansPhysicalFunction.cpp) add_plugin(TfloatScaleValue PhysicalFunction nes-physical-operators TfloatScaleValuePhysicalFunction.cpp) add_plugin(AddTfloatFloat PhysicalFunction nes-physical-operators AddTfloatFloatPhysicalFunction.cpp) +add_plugin(AddTnumberTnumber PhysicalFunction nes-physical-operators AddTnumberTnumberPhysicalFunction.cpp) +add_plugin(DivTnumberTnumber PhysicalFunction nes-physical-operators DivTnumberTnumberPhysicalFunction.cpp) +add_plugin(MulTnumberTnumber PhysicalFunction nes-physical-operators MulTnumberTnumberPhysicalFunction.cpp) +add_plugin(SubTnumberTnumber PhysicalFunction nes-physical-operators SubTnumberTnumberPhysicalFunction.cpp) add_plugin(DivTfloatFloat PhysicalFunction nes-physical-operators DivTfloatFloatPhysicalFunction.cpp) add_plugin(MulTfloatFloat PhysicalFunction nes-physical-operators MulTfloatFloatPhysicalFunction.cpp) add_plugin(SubTfloatFloat PhysicalFunction nes-physical-operators SubTfloatFloatPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/DivTnumberTnumberPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/DivTnumberTnumberPhysicalFunction.cpp new file mode 100644 index 0000000000..1cab4168d2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/DivTnumberTnumberPhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +DivTnumberTnumberPhysicalFunction::DivTnumberTnumberPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal DivTnumberTnumberPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value1, double value2, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + const std::string tsStr = MEOS::Meos::convertEpochToTimestamp(ts); + std::string wkt1 = fmt::format("{}@{}", value1, tsStr); + std::string wkt2 = fmt::format("{}@{}", value2, tsStr); + Temporal* t1 = tfloat_in(wkt1.c_str()); + Temporal* t2 = tfloat_in(wkt2.c_str()); + if (!t1 || !t2) { free(t1); free(t2); return 0.0; } + Temporal* res = div_tnumber_tnumber(t1, t2); + free(t1); free(t2); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterDivTnumberTnumberPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "DivTnumberTnumberPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return DivTnumberTnumberPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/MulTnumberTnumberPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/MulTnumberTnumberPhysicalFunction.cpp new file mode 100644 index 0000000000..30f600c42b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/MulTnumberTnumberPhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +MulTnumberTnumberPhysicalFunction::MulTnumberTnumberPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal MulTnumberTnumberPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value1, double value2, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + const std::string tsStr = MEOS::Meos::convertEpochToTimestamp(ts); + std::string wkt1 = fmt::format("{}@{}", value1, tsStr); + std::string wkt2 = fmt::format("{}@{}", value2, tsStr); + Temporal* t1 = tfloat_in(wkt1.c_str()); + Temporal* t2 = tfloat_in(wkt2.c_str()); + if (!t1 || !t2) { free(t1); free(t2); return 0.0; } + Temporal* res = mul_tnumber_tnumber(t1, t2); + free(t1); free(t2); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterMulTnumberTnumberPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "MulTnumberTnumberPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return MulTnumberTnumberPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/SubTnumberTnumberPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/SubTnumberTnumberPhysicalFunction.cpp new file mode 100644 index 0000000000..4c57908824 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/SubTnumberTnumberPhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +SubTnumberTnumberPhysicalFunction::SubTnumberTnumberPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal SubTnumberTnumberPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value1, double value2, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + const std::string tsStr = MEOS::Meos::convertEpochToTimestamp(ts); + std::string wkt1 = fmt::format("{}@{}", value1, tsStr); + std::string wkt2 = fmt::format("{}@{}", value2, tsStr); + Temporal* t1 = tfloat_in(wkt1.c_str()); + Temporal* t2 = tfloat_in(wkt2.c_str()); + if (!t1 || !t2) { free(t1); free(t2); return 0.0; } + Temporal* res = sub_tnumber_tnumber(t1, t2); + free(t1); free(t2); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterSubTnumberTnumberPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "SubTnumberTnumberPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return SubTnumberTnumberPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 893cd4b5d3..379cf86cd1 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | DIV_TFLOAT_FLOAT | MUL_TFLOAT_FLOAT | SUB_TFLOAT_FLOAT | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | ADD_TNUMBER_TNUMBER | DIV_TFLOAT_FLOAT | DIV_TNUMBER_TNUMBER | MUL_TFLOAT_FLOAT | MUL_TNUMBER_TNUMBER | SUB_TFLOAT_FLOAT | SUB_TNUMBER_TNUMBER | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -489,9 +489,13 @@ TEMPORAL_ECONTAINS_GEOMETRY: 'TEMPORAL_ECONTAINS_GEOMETRY' | 'temporal_econtains EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; TGEO_AT_STBOX: 'TGEO_AT_STBOX' | 'tgeo_at_stbox'; ADD_TFLOAT_FLOAT: 'ADD_TFLOAT_FLOAT' | 'add_tfloat_float'; +ADD_TNUMBER_TNUMBER: 'ADD_TNUMBER_TNUMBER' | 'add_tnumber_tnumber'; DIV_TFLOAT_FLOAT: 'DIV_TFLOAT_FLOAT' | 'div_tfloat_float'; +DIV_TNUMBER_TNUMBER: 'DIV_TNUMBER_TNUMBER' | 'div_tnumber_tnumber'; MUL_TFLOAT_FLOAT: 'MUL_TFLOAT_FLOAT' | 'mul_tfloat_float'; +MUL_TNUMBER_TNUMBER: 'MUL_TNUMBER_TNUMBER' | 'mul_tnumber_tnumber'; SUB_TFLOAT_FLOAT: 'SUB_TFLOAT_FLOAT' | 'sub_tfloat_float'; +SUB_TNUMBER_TNUMBER: 'SUB_TNUMBER_TNUMBER' | 'sub_tnumber_tnumber'; TFLOAT_CEIL: 'TFLOAT_CEIL' | 'tfloat_ceil'; TFLOAT_COS: 'TFLOAT_COS' | 'tfloat_cos'; TFLOAT_DEGREES: 'TFLOAT_DEGREES' | 'tfloat_degrees'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 6fc7f008dc..8af91b5966 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -70,9 +70,13 @@ #include #include #include +#include #include +#include #include +#include #include +#include #include #include #include @@ -1630,6 +1634,122 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: SUB_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ADD_TNUMBER_TNUMBER */ + case AntlrSQLLexer::ADD_TNUMBER_TNUMBER: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ADD_TNUMBER_TNUMBER requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AddTnumberTnumberLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ADD_TNUMBER_TNUMBER */ + /* BEGIN CODEGEN PARSER GLUE: DIV_TNUMBER_TNUMBER */ + case AntlrSQLLexer::DIV_TNUMBER_TNUMBER: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("DIV_TNUMBER_TNUMBER requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(DivTnumberTnumberLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: DIV_TNUMBER_TNUMBER */ + /* BEGIN CODEGEN PARSER GLUE: MUL_TNUMBER_TNUMBER */ + case AntlrSQLLexer::MUL_TNUMBER_TNUMBER: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("MUL_TNUMBER_TNUMBER requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(MulTnumberTnumberLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: MUL_TNUMBER_TNUMBER */ + /* BEGIN CODEGEN PARSER GLUE: SUB_TNUMBER_TNUMBER */ + case AntlrSQLLexer::SUB_TNUMBER_TNUMBER: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("SUB_TNUMBER_TNUMBER requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(SubTnumberTnumberLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: SUB_TNUMBER_TNUMBER */ default: /// Check if the function is a constructor for a datatype From 69172abb64d87bcdeb9f200768bafb5aed4f0945 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 05:52:35 +0200 Subject: [PATCH 08/86] feat(meos): add TEMPORAL_ROUND, TDISTANCE_TFLOAT_FLOAT, TDISTANCE_TNUMBER_TNUMBER NES operators (W50) Adds per-event NES operators backed by temporal_round (3-arg: value, ts, maxdd), tdistance_tfloat_float (3-arg: value, ts, d), and tdistance_tnumber_tnumber (3-arg: value1, value2, ts). Each operator constructs one or two co-instant tfloats, applies the MEOS function, and returns the resulting double. Logical/physical function pairs, plugin registrations, grammar tokens, and parser case blocks are included. --- .../TdistanceTfloatFloatLogicalFunction.hpp | 54 +++++++++ ...TdistanceTnumberTnumberLogicalFunction.hpp | 54 +++++++++ .../Meos/TemporalRoundLogicalFunction.hpp | 54 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../TdistanceTfloatFloatLogicalFunction.cpp | 105 ++++++++++++++++++ ...TdistanceTnumberTnumberLogicalFunction.cpp | 105 ++++++++++++++++++ .../Meos/TemporalRoundLogicalFunction.cpp | 105 ++++++++++++++++++ .../TdistanceTfloatFloatPhysicalFunction.hpp | 43 +++++++ ...distanceTnumberTnumberPhysicalFunction.hpp | 43 +++++++ .../Meos/TemporalRoundPhysicalFunction.hpp | 43 +++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../TdistanceTfloatFloatPhysicalFunction.cpp | 91 +++++++++++++++ ...distanceTnumberTnumberPhysicalFunction.cpp | 94 ++++++++++++++++ .../Meos/TemporalRoundPhysicalFunction.cpp | 91 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 5 +- .../src/AntlrSQLQueryPlanCreator.cpp | 90 +++++++++++++++ 16 files changed, 982 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TdistanceTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TdistanceTnumberTnumberLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TemporalRoundLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TdistanceTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TdistanceTnumberTnumberLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TemporalRoundLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TdistanceTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TdistanceTnumberTnumberPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TemporalRoundPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TdistanceTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TdistanceTnumberTnumberPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TemporalRoundPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TdistanceTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TdistanceTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..0404bd65b5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TdistanceTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tdistance_tfloat_float: distance between a single-instant tfloat and a float. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tdistance_tfloat_float`. Takes (value:FLOAT64, ts:UINT64, d:FLOAT64), + * constructs a single-instant temporal, applies the distance function, and returns FLOAT64. + */ +class TdistanceTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TdistanceTfloatFloat"; + + TdistanceTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction d); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TdistanceTnumberTnumberLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TdistanceTnumberTnumberLogicalFunction.hpp new file mode 100644 index 0000000000..1f9f544348 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TdistanceTnumberTnumberLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tdistance_tnumber_tnumber: distance between two co-instant tnumber values. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tdistance_tnumber_tnumber`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two co-instant temporals, applies the distance function, and returns FLOAT64. + */ +class TdistanceTnumberTnumberLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TdistanceTnumberTnumber"; + + TdistanceTnumberTnumberLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TemporalRoundLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TemporalRoundLogicalFunction.hpp new file mode 100644 index 0000000000..987761a0df --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TemporalRoundLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event temporal_round: rounds a single-instant tfloat to N decimal places. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `temporal_round`. Takes (value:FLOAT64, ts:UINT64, maxdd:FLOAT64→int), + * constructs a single-instant temporal, applies the rounding, and returns FLOAT64. + */ +class TemporalRoundLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TemporalRound"; + + TemporalRoundLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction maxdd); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index c2debfca0e..a58cf4184b 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -26,6 +26,9 @@ add_plugin(TfloatRadians LogicalFunction nes-logical-operators TfloatRadiansLogi add_plugin(TfloatScaleValue LogicalFunction nes-logical-operators TfloatScaleValueLogicalFunction.cpp) add_plugin(AddTfloatFloat LogicalFunction nes-logical-operators AddTfloatFloatLogicalFunction.cpp) add_plugin(AddTnumberTnumber LogicalFunction nes-logical-operators AddTnumberTnumberLogicalFunction.cpp) +add_plugin(TdistanceTfloatFloat LogicalFunction nes-logical-operators TdistanceTfloatFloatLogicalFunction.cpp) +add_plugin(TdistanceTnumberTnumber LogicalFunction nes-logical-operators TdistanceTnumberTnumberLogicalFunction.cpp) +add_plugin(TemporalRound LogicalFunction nes-logical-operators TemporalRoundLogicalFunction.cpp) add_plugin(DivTnumberTnumber LogicalFunction nes-logical-operators DivTnumberTnumberLogicalFunction.cpp) add_plugin(MulTnumberTnumber LogicalFunction nes-logical-operators MulTnumberTnumberLogicalFunction.cpp) add_plugin(SubTnumberTnumber LogicalFunction nes-logical-operators SubTnumberTnumberLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TdistanceTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TdistanceTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..3532410708 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TdistanceTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TdistanceTfloatFloatLogicalFunction::TdistanceTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction d) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(d)); +} + +DataType TdistanceTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TdistanceTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TdistanceTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TdistanceTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TdistanceTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TdistanceTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool TdistanceTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TdistanceTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TdistanceTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TdistanceTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTdistanceTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TdistanceTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TdistanceTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TdistanceTnumberTnumberLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TdistanceTnumberTnumberLogicalFunction.cpp new file mode 100644 index 0000000000..2ff41374c1 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TdistanceTnumberTnumberLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TdistanceTnumberTnumberLogicalFunction::TdistanceTnumberTnumberLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType TdistanceTnumberTnumberLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TdistanceTnumberTnumberLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TdistanceTnumberTnumberLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TdistanceTnumberTnumberLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TdistanceTnumberTnumberLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TdistanceTnumberTnumberLogicalFunction::getType() const { return NAME; } + +bool TdistanceTnumberTnumberLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TdistanceTnumberTnumberLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TdistanceTnumberTnumberLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TdistanceTnumberTnumberLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTdistanceTnumberTnumberLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TdistanceTnumberTnumberLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TdistanceTnumberTnumberLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TemporalRoundLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TemporalRoundLogicalFunction.cpp new file mode 100644 index 0000000000..95163814fd --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TemporalRoundLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TemporalRoundLogicalFunction::TemporalRoundLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction maxdd) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(maxdd)); +} + +DataType TemporalRoundLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TemporalRoundLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TemporalRoundLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TemporalRoundLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TemporalRoundLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TemporalRoundLogicalFunction::getType() const { return NAME; } + +bool TemporalRoundLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TemporalRoundLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TemporalRoundLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TemporalRoundLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTemporalRoundLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TemporalRoundLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TemporalRoundLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TdistanceTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TdistanceTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..06bf692313 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TdistanceTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tdistance_tfloat_float`. + * + * Per-event tdistance_tfloat_float: distance between a single-instant tfloat and a float. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TdistanceTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TdistanceTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction dFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TdistanceTnumberTnumberPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TdistanceTnumberTnumberPhysicalFunction.hpp new file mode 100644 index 0000000000..107d00bae1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TdistanceTnumberTnumberPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tdistance_tnumber_tnumber`. + * + * Per-event tdistance_tnumber_tnumber: distance between two co-instant tnumber values. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TdistanceTnumberTnumberPhysicalFunction : public PhysicalFunctionConcept { +public: + TdistanceTnumberTnumberPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TemporalRoundPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TemporalRoundPhysicalFunction.hpp new file mode 100644 index 0000000000..4b169faee3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TemporalRoundPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `temporal_round`. + * + * Per-event temporal_round: rounds a single-instant tfloat to N decimal places. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TemporalRoundPhysicalFunction : public PhysicalFunctionConcept { +public: + TemporalRoundPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction maxddFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index de2aeb2de3..d3c9c131b4 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -25,6 +25,9 @@ add_plugin(TfloatRadians PhysicalFunction nes-physical-operators TfloatRadiansPh add_plugin(TfloatScaleValue PhysicalFunction nes-physical-operators TfloatScaleValuePhysicalFunction.cpp) add_plugin(AddTfloatFloat PhysicalFunction nes-physical-operators AddTfloatFloatPhysicalFunction.cpp) add_plugin(AddTnumberTnumber PhysicalFunction nes-physical-operators AddTnumberTnumberPhysicalFunction.cpp) +add_plugin(TdistanceTfloatFloat PhysicalFunction nes-physical-operators TdistanceTfloatFloatPhysicalFunction.cpp) +add_plugin(TdistanceTnumberTnumber PhysicalFunction nes-physical-operators TdistanceTnumberTnumberPhysicalFunction.cpp) +add_plugin(TemporalRound PhysicalFunction nes-physical-operators TemporalRoundPhysicalFunction.cpp) add_plugin(DivTnumberTnumber PhysicalFunction nes-physical-operators DivTnumberTnumberPhysicalFunction.cpp) add_plugin(MulTnumberTnumber PhysicalFunction nes-physical-operators MulTnumberTnumberPhysicalFunction.cpp) add_plugin(SubTnumberTnumber PhysicalFunction nes-physical-operators SubTnumberTnumberPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/TdistanceTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TdistanceTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..f32584b1fc --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TdistanceTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TdistanceTfloatFloatPhysicalFunction::TdistanceTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction dFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(dFunction)); +} + +VarVal TdistanceTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto d = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tdistance_tfloat_float(temp, d); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, d); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTdistanceTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TdistanceTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TdistanceTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TdistanceTnumberTnumberPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TdistanceTnumberTnumberPhysicalFunction.cpp new file mode 100644 index 0000000000..26696f4bb7 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TdistanceTnumberTnumberPhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TdistanceTnumberTnumberPhysicalFunction::TdistanceTnumberTnumberPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TdistanceTnumberTnumberPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value1, double value2, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + const std::string tsStr = MEOS::Meos::convertEpochToTimestamp(ts); + std::string wkt1 = fmt::format("{}@{}", value1, tsStr); + std::string wkt2 = fmt::format("{}@{}", value2, tsStr); + Temporal* t1 = tfloat_in(wkt1.c_str()); + Temporal* t2 = tfloat_in(wkt2.c_str()); + if (!t1 || !t2) { free(t1); free(t2); return 0.0; } + Temporal* res = tdistance_tnumber_tnumber(t1, t2); + free(t1); free(t2); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTdistanceTnumberTnumberPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TdistanceTnumberTnumberPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TdistanceTnumberTnumberPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TemporalRoundPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TemporalRoundPhysicalFunction.cpp new file mode 100644 index 0000000000..8836fe5bdf --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TemporalRoundPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TemporalRoundPhysicalFunction::TemporalRoundPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction maxddFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(maxddFunction)); +} + +VarVal TemporalRoundPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto maxdd = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double maxdd_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = temporal_round(temp, static_cast(maxdd_d)); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, maxdd); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTemporalRoundPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TemporalRoundPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TemporalRoundPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 379cf86cd1..f4fd7a6858 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | ADD_TNUMBER_TNUMBER | DIV_TFLOAT_FLOAT | DIV_TNUMBER_TNUMBER | MUL_TFLOAT_FLOAT | MUL_TNUMBER_TNUMBER | SUB_TFLOAT_FLOAT | SUB_TNUMBER_TNUMBER | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | ADD_TNUMBER_TNUMBER | DIV_TFLOAT_FLOAT | DIV_TNUMBER_TNUMBER | MUL_TFLOAT_FLOAT | MUL_TNUMBER_TNUMBER | SUB_TFLOAT_FLOAT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -496,6 +496,9 @@ MUL_TFLOAT_FLOAT: 'MUL_TFLOAT_FLOAT' | 'mul_tfloat_float'; MUL_TNUMBER_TNUMBER: 'MUL_TNUMBER_TNUMBER' | 'mul_tnumber_tnumber'; SUB_TFLOAT_FLOAT: 'SUB_TFLOAT_FLOAT' | 'sub_tfloat_float'; SUB_TNUMBER_TNUMBER: 'SUB_TNUMBER_TNUMBER' | 'sub_tnumber_tnumber'; +TDISTANCE_TFLOAT_FLOAT: 'TDISTANCE_TFLOAT_FLOAT' | 'tdistance_tfloat_float'; +TDISTANCE_TNUMBER_TNUMBER: 'TDISTANCE_TNUMBER_TNUMBER' | 'tdistance_tnumber_tnumber'; +TEMPORAL_ROUND: 'TEMPORAL_ROUND' | 'temporal_round'; TFLOAT_CEIL: 'TFLOAT_CEIL' | 'tfloat_ceil'; TFLOAT_COS: 'TFLOAT_COS' | 'tfloat_cos'; TFLOAT_DEGREES: 'TFLOAT_DEGREES' | 'tfloat_degrees'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 8af91b5966..de68032c01 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -77,6 +77,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -1751,6 +1754,93 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont break; /* END CODEGEN PARSER GLUE: SUB_TNUMBER_TNUMBER */ + case AntlrSQLLexer::TDISTANCE_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TDISTANCE_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TdistanceTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TDISTANCE_TFLOAT_FLOAT */ + + case AntlrSQLLexer::TDISTANCE_TNUMBER_TNUMBER: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TDISTANCE_TNUMBER_TNUMBER requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TdistanceTnumberTnumberLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TDISTANCE_TNUMBER_TNUMBER */ + + case AntlrSQLLexer::TEMPORAL_ROUND: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TEMPORAL_ROUND requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TemporalRoundLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TEMPORAL_ROUND */ + default: /// Check if the function is a constructor for a datatype if (const auto dataType = DataTypeProvider::tryProvideDataType(funcName); dataType.has_value()) From b789cafb8df066c736a178f512cc54143e85ee60 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 05:58:40 +0200 Subject: [PATCH 09/86] feat(meos): add ADD/SUB/MUL/DIV_TINT_INT NES operators (W51) Adds per-event NES operators backed by add_tint_int, sub_tint_int, mul_tint_int, and div_tint_int (3-arg each: value, ts, scalar_int). Each operator constructs a single-instant tint, applies the MEOS integer arithmetic function, and returns the resulting integer as FLOAT64. Logical/physical function pairs, plugin registrations, grammar tokens, and parser case blocks are included. --- .../Meos/AddTintIntLogicalFunction.hpp | 54 ++++++++ .../Meos/DivTintIntLogicalFunction.hpp | 54 ++++++++ .../Meos/MulTintIntLogicalFunction.hpp | 54 ++++++++ .../Meos/SubTintIntLogicalFunction.hpp | 54 ++++++++ .../Meos/AddTintIntLogicalFunction.cpp | 105 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/DivTintIntLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/MulTintIntLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/SubTintIntLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/AddTintIntPhysicalFunction.hpp | 43 +++++++ .../Meos/DivTintIntPhysicalFunction.hpp | 43 +++++++ .../Meos/MulTintIntPhysicalFunction.hpp | 43 +++++++ .../Meos/SubTintIntPhysicalFunction.hpp | 43 +++++++ .../Meos/AddTintIntPhysicalFunction.cpp | 91 +++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/DivTintIntPhysicalFunction.cpp | 91 +++++++++++++ .../Meos/MulTintIntPhysicalFunction.cpp | 91 +++++++++++++ .../Meos/SubTintIntPhysicalFunction.cpp | 91 +++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 121 ++++++++++++++++++ 20 files changed, 1306 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AddTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/DivTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/MulTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/SubTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AddTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/DivTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/MulTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/SubTintIntLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AddTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/DivTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/MulTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/SubTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AddTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/DivTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/MulTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/SubTintIntPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AddTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AddTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..c38de2cff9 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AddTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event add_tint_int: adds a constant integer to a single-instant tint value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `add_tint_int`. Takes (value:FLOAT64, ts:UINT64, addend:FLOAT64→int), + * constructs a single-instant temporal, applies the addition, and returns FLOAT64. + */ +class AddTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AddTintInt"; + + AddTintIntLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction addend); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/DivTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/DivTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..3c201c5b16 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/DivTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event div_tint_int: divides a single-instant tint value by a constant integer. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `div_tint_int`. Takes (value:FLOAT64, ts:UINT64, divisor:FLOAT64→int), + * constructs a single-instant temporal, applies the division, and returns FLOAT64. + */ +class DivTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "DivTintInt"; + + DivTintIntLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction divisor); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/MulTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/MulTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..bf2fbb90b5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/MulTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event mul_tint_int: multiplies a single-instant tint value by a constant integer. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `mul_tint_int`. Takes (value:FLOAT64, ts:UINT64, multiplier:FLOAT64→int), + * constructs a single-instant temporal, applies the multiplication, and returns FLOAT64. + */ +class MulTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "MulTintInt"; + + MulTintIntLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction multiplier); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/SubTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/SubTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..49c77fc4d3 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/SubTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event sub_tint_int: subtracts a constant integer from a single-instant tint value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `sub_tint_int`. Takes (value:FLOAT64, ts:UINT64, subtrahend:FLOAT64→int), + * constructs a single-instant temporal, applies the subtraction, and returns FLOAT64. + */ +class SubTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "SubTintInt"; + + SubTintIntLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction subtrahend); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AddTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AddTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..a788921856 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AddTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AddTintIntLogicalFunction::AddTintIntLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction addend) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(addend)); +} + +DataType AddTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AddTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AddTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AddTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AddTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AddTintIntLogicalFunction::getType() const { return NAME; } + +bool AddTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AddTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AddTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AddTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAddTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AddTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AddTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index a58cf4184b..5734d5a728 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -25,12 +25,16 @@ add_plugin(TfloatFloor LogicalFunction nes-logical-operators TfloatFloorLogicalF add_plugin(TfloatRadians LogicalFunction nes-logical-operators TfloatRadiansLogicalFunction.cpp) add_plugin(TfloatScaleValue LogicalFunction nes-logical-operators TfloatScaleValueLogicalFunction.cpp) add_plugin(AddTfloatFloat LogicalFunction nes-logical-operators AddTfloatFloatLogicalFunction.cpp) +add_plugin(AddTintInt LogicalFunction nes-logical-operators AddTintIntLogicalFunction.cpp) add_plugin(AddTnumberTnumber LogicalFunction nes-logical-operators AddTnumberTnumberLogicalFunction.cpp) add_plugin(TdistanceTfloatFloat LogicalFunction nes-logical-operators TdistanceTfloatFloatLogicalFunction.cpp) add_plugin(TdistanceTnumberTnumber LogicalFunction nes-logical-operators TdistanceTnumberTnumberLogicalFunction.cpp) add_plugin(TemporalRound LogicalFunction nes-logical-operators TemporalRoundLogicalFunction.cpp) +add_plugin(DivTintInt LogicalFunction nes-logical-operators DivTintIntLogicalFunction.cpp) add_plugin(DivTnumberTnumber LogicalFunction nes-logical-operators DivTnumberTnumberLogicalFunction.cpp) +add_plugin(MulTintInt LogicalFunction nes-logical-operators MulTintIntLogicalFunction.cpp) add_plugin(MulTnumberTnumber LogicalFunction nes-logical-operators MulTnumberTnumberLogicalFunction.cpp) +add_plugin(SubTintInt LogicalFunction nes-logical-operators SubTintIntLogicalFunction.cpp) add_plugin(SubTnumberTnumber LogicalFunction nes-logical-operators SubTnumberTnumberLogicalFunction.cpp) add_plugin(DivTfloatFloat LogicalFunction nes-logical-operators DivTfloatFloatLogicalFunction.cpp) add_plugin(MulTfloatFloat LogicalFunction nes-logical-operators MulTfloatFloatLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/DivTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/DivTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..723116937f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/DivTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +DivTintIntLogicalFunction::DivTintIntLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction divisor) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(divisor)); +} + +DataType DivTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction DivTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector DivTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction DivTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "DivTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view DivTintIntLogicalFunction::getType() const { return NAME; } + +bool DivTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string DivTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction DivTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction DivTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterDivTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "DivTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return DivTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/MulTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/MulTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..e973fe3aa8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/MulTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +MulTintIntLogicalFunction::MulTintIntLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction multiplier) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(multiplier)); +} + +DataType MulTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction MulTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector MulTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction MulTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "MulTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view MulTintIntLogicalFunction::getType() const { return NAME; } + +bool MulTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string MulTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction MulTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction MulTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterMulTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "MulTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return MulTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/SubTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/SubTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..1b18e51bce --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/SubTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +SubTintIntLogicalFunction::SubTintIntLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction subtrahend) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(subtrahend)); +} + +DataType SubTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction SubTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector SubTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction SubTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "SubTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view SubTintIntLogicalFunction::getType() const { return NAME; } + +bool SubTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string SubTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction SubTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction SubTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterSubTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "SubTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return SubTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AddTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AddTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..e2fd8daba7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AddTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `add_tint_int`. + * + * Per-event add_tint_int: adds a constant integer to a single-instant tint value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AddTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + AddTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction addendFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/DivTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/DivTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..40c7f5a1a3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/DivTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `div_tint_int`. + * + * Per-event div_tint_int: divides a single-instant tint value by a constant integer. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class DivTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + DivTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction divisorFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/MulTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/MulTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..8f3215281f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/MulTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `mul_tint_int`. + * + * Per-event mul_tint_int: multiplies a single-instant tint value by a constant integer. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class MulTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + MulTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction multiplierFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/SubTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/SubTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..d7792e3f00 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/SubTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `sub_tint_int`. + * + * Per-event sub_tint_int: subtracts a constant integer from a single-instant tint value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class SubTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + SubTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction subtrahendFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AddTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AddTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..031a677e61 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AddTintIntPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AddTintIntPhysicalFunction::AddTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction addendFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(addendFunction)); +} + +VarVal AddTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto addend = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double addend_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = add_tint_int(temp, static_cast(addend_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, addend); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAddTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AddTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AddTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index d3c9c131b4..1b7168a2c2 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -24,12 +24,16 @@ add_plugin(TfloatFloor PhysicalFunction nes-physical-operators TfloatFloorPhysic add_plugin(TfloatRadians PhysicalFunction nes-physical-operators TfloatRadiansPhysicalFunction.cpp) add_plugin(TfloatScaleValue PhysicalFunction nes-physical-operators TfloatScaleValuePhysicalFunction.cpp) add_plugin(AddTfloatFloat PhysicalFunction nes-physical-operators AddTfloatFloatPhysicalFunction.cpp) +add_plugin(AddTintInt PhysicalFunction nes-physical-operators AddTintIntPhysicalFunction.cpp) add_plugin(AddTnumberTnumber PhysicalFunction nes-physical-operators AddTnumberTnumberPhysicalFunction.cpp) add_plugin(TdistanceTfloatFloat PhysicalFunction nes-physical-operators TdistanceTfloatFloatPhysicalFunction.cpp) add_plugin(TdistanceTnumberTnumber PhysicalFunction nes-physical-operators TdistanceTnumberTnumberPhysicalFunction.cpp) add_plugin(TemporalRound PhysicalFunction nes-physical-operators TemporalRoundPhysicalFunction.cpp) +add_plugin(DivTintInt PhysicalFunction nes-physical-operators DivTintIntPhysicalFunction.cpp) add_plugin(DivTnumberTnumber PhysicalFunction nes-physical-operators DivTnumberTnumberPhysicalFunction.cpp) +add_plugin(MulTintInt PhysicalFunction nes-physical-operators MulTintIntPhysicalFunction.cpp) add_plugin(MulTnumberTnumber PhysicalFunction nes-physical-operators MulTnumberTnumberPhysicalFunction.cpp) +add_plugin(SubTintInt PhysicalFunction nes-physical-operators SubTintIntPhysicalFunction.cpp) add_plugin(SubTnumberTnumber PhysicalFunction nes-physical-operators SubTnumberTnumberPhysicalFunction.cpp) add_plugin(DivTfloatFloat PhysicalFunction nes-physical-operators DivTfloatFloatPhysicalFunction.cpp) add_plugin(MulTfloatFloat PhysicalFunction nes-physical-operators MulTfloatFloatPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/DivTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/DivTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..540c8b52e3 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/DivTintIntPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +DivTintIntPhysicalFunction::DivTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction divisorFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(divisorFunction)); +} + +VarVal DivTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto divisor = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double divisor_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = div_tint_int(temp, static_cast(divisor_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, divisor); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterDivTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "DivTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return DivTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/MulTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/MulTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..18b90450ae --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/MulTintIntPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +MulTintIntPhysicalFunction::MulTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction multiplierFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(multiplierFunction)); +} + +VarVal MulTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto multiplier = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double multiplier_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = mul_tint_int(temp, static_cast(multiplier_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, multiplier); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterMulTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "MulTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return MulTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/SubTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/SubTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..c086705591 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/SubTintIntPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +SubTintIntPhysicalFunction::SubTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction subtrahendFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(subtrahendFunction)); +} + +VarVal SubTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto subtrahend = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double subtrahend_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = sub_tint_int(temp, static_cast(subtrahend_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, subtrahend); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterSubTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "SubTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return SubTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index f4fd7a6858..f41484aa70 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | ADD_TNUMBER_TNUMBER | DIV_TFLOAT_FLOAT | DIV_TNUMBER_TNUMBER | MUL_TFLOAT_FLOAT | MUL_TNUMBER_TNUMBER | SUB_TFLOAT_FLOAT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -489,12 +489,16 @@ TEMPORAL_ECONTAINS_GEOMETRY: 'TEMPORAL_ECONTAINS_GEOMETRY' | 'temporal_econtains EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; TGEO_AT_STBOX: 'TGEO_AT_STBOX' | 'tgeo_at_stbox'; ADD_TFLOAT_FLOAT: 'ADD_TFLOAT_FLOAT' | 'add_tfloat_float'; +ADD_TINT_INT: 'ADD_TINT_INT' | 'add_tint_int'; ADD_TNUMBER_TNUMBER: 'ADD_TNUMBER_TNUMBER' | 'add_tnumber_tnumber'; DIV_TFLOAT_FLOAT: 'DIV_TFLOAT_FLOAT' | 'div_tfloat_float'; +DIV_TINT_INT: 'DIV_TINT_INT' | 'div_tint_int'; DIV_TNUMBER_TNUMBER: 'DIV_TNUMBER_TNUMBER' | 'div_tnumber_tnumber'; MUL_TFLOAT_FLOAT: 'MUL_TFLOAT_FLOAT' | 'mul_tfloat_float'; +MUL_TINT_INT: 'MUL_TINT_INT' | 'mul_tint_int'; MUL_TNUMBER_TNUMBER: 'MUL_TNUMBER_TNUMBER' | 'mul_tnumber_tnumber'; SUB_TFLOAT_FLOAT: 'SUB_TFLOAT_FLOAT' | 'sub_tfloat_float'; +SUB_TINT_INT: 'SUB_TINT_INT' | 'sub_tint_int'; SUB_TNUMBER_TNUMBER: 'SUB_TNUMBER_TNUMBER' | 'sub_tnumber_tnumber'; TDISTANCE_TFLOAT_FLOAT: 'TDISTANCE_TFLOAT_FLOAT' | 'tdistance_tfloat_float'; TDISTANCE_TNUMBER_TNUMBER: 'TDISTANCE_TNUMBER_TNUMBER' | 'tdistance_tnumber_tnumber'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index de68032c01..0ed1f77265 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -70,12 +70,16 @@ #include #include #include +#include #include #include +#include #include #include +#include #include #include +#include #include #include #include @@ -1637,6 +1641,123 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: SUB_TFLOAT_FLOAT */ + + case AntlrSQLLexer::ADD_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ADD_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AddTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ADD_TINT_INT */ + + case AntlrSQLLexer::DIV_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("DIV_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(DivTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: DIV_TINT_INT */ + + case AntlrSQLLexer::MUL_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("MUL_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(MulTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: MUL_TINT_INT */ + + case AntlrSQLLexer::SUB_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("SUB_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(SubTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: SUB_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: ADD_TNUMBER_TNUMBER */ case AntlrSQLLexer::ADD_TNUMBER_TNUMBER: { From e64267ac6c6d0ee90bd167a1426e69f387a0784b Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 06:07:19 +0200 Subject: [PATCH 10/86] feat(meos): add TDISTANCE_TINT_INT, TINT_SHIFT_VALUE, TINT_SCALE_VALUE, TINT_SHIFT_SCALE_VALUE NES operators (W52) --- .../Meos/TdistanceTintIntLogicalFunction.hpp | 54 ++++++++ .../Meos/TintScaleValueLogicalFunction.hpp | 54 ++++++++ .../TintShiftScaleValueLogicalFunction.hpp | 55 ++++++++ .../Meos/TintShiftValueLogicalFunction.hpp | 54 ++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/TdistanceTintIntLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/TintScaleValueLogicalFunction.cpp | 105 +++++++++++++++ .../TintShiftScaleValueLogicalFunction.cpp | 108 ++++++++++++++++ .../Meos/TintShiftValueLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/TdistanceTintIntPhysicalFunction.hpp | 44 +++++++ .../Meos/TintScaleValuePhysicalFunction.hpp | 44 +++++++ .../TintShiftScaleValuePhysicalFunction.hpp | 45 +++++++ .../Meos/TintShiftValuePhysicalFunction.hpp | 44 +++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/TdistanceTintIntPhysicalFunction.cpp | 91 +++++++++++++ .../Meos/TintScaleValuePhysicalFunction.cpp | 91 +++++++++++++ .../TintShiftScaleValuePhysicalFunction.cpp | 95 ++++++++++++++ .../Meos/TintShiftValuePhysicalFunction.cpp | 91 +++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 121 ++++++++++++++++++ 20 files changed, 1319 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TdistanceTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TintScaleValueLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TintShiftScaleValueLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TintShiftValueLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TdistanceTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TintScaleValueLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TintShiftScaleValueLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TintShiftValueLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TdistanceTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TintScaleValuePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TintShiftScaleValuePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TintShiftValuePhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TdistanceTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TintScaleValuePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TintShiftScaleValuePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TintShiftValuePhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TdistanceTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TdistanceTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..a8baa981f0 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TdistanceTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tdistance_tint_int: distance between a single-instant tint and an integer. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tdistance_tint_int`. Takes (value:FLOAT64, ts:UINT64, d:FLOAT64→int), + * constructs a single-instant temporal, applies the distance function, and returns FLOAT64. + */ +class TdistanceTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TdistanceTintInt"; + + TdistanceTintIntLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction d); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TintScaleValueLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TintScaleValueLogicalFunction.hpp new file mode 100644 index 0000000000..eaf261f031 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TintScaleValueLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tint_scale_value: scales a single-instant tint to a given width. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tint_scale_value`. Takes (value:FLOAT64, ts:UINT64, width:FLOAT64→int), + * constructs a single-instant temporal, applies the scale, and returns FLOAT64. + */ +class TintScaleValueLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TintScaleValue"; + + TintScaleValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction width); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TintShiftScaleValueLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TintShiftScaleValueLogicalFunction.hpp new file mode 100644 index 0000000000..4b3ec6c91e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TintShiftScaleValueLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tint_shift_scale_value: shifts and scales a single-instant tint. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tint_shift_scale_value`. Takes (value:FLOAT64, ts:UINT64, shift:FLOAT64→int, width:FLOAT64→int), + * constructs a single-instant temporal, applies the shift-and-scale, and returns FLOAT64. + */ +class TintShiftScaleValueLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TintShiftScaleValue"; + + TintShiftScaleValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction shift, + LogicalFunction width); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TintShiftValueLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TintShiftValueLogicalFunction.hpp new file mode 100644 index 0000000000..ebf94d3dd8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TintShiftValueLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tint_shift_value: shifts a single-instant tint by a constant integer. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tint_shift_value`. Takes (value:FLOAT64, ts:UINT64, shift:FLOAT64→int), + * constructs a single-instant temporal, applies the shift, and returns FLOAT64. + */ +class TintShiftValueLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TintShiftValue"; + + TintShiftValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction shift); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 5734d5a728..49cd3f9231 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -28,8 +28,12 @@ add_plugin(AddTfloatFloat LogicalFunction nes-logical-operators AddTfloatFloatLo add_plugin(AddTintInt LogicalFunction nes-logical-operators AddTintIntLogicalFunction.cpp) add_plugin(AddTnumberTnumber LogicalFunction nes-logical-operators AddTnumberTnumberLogicalFunction.cpp) add_plugin(TdistanceTfloatFloat LogicalFunction nes-logical-operators TdistanceTfloatFloatLogicalFunction.cpp) +add_plugin(TdistanceTintInt LogicalFunction nes-logical-operators TdistanceTintIntLogicalFunction.cpp) add_plugin(TdistanceTnumberTnumber LogicalFunction nes-logical-operators TdistanceTnumberTnumberLogicalFunction.cpp) add_plugin(TemporalRound LogicalFunction nes-logical-operators TemporalRoundLogicalFunction.cpp) +add_plugin(TintScaleValue LogicalFunction nes-logical-operators TintScaleValueLogicalFunction.cpp) +add_plugin(TintShiftScaleValue LogicalFunction nes-logical-operators TintShiftScaleValueLogicalFunction.cpp) +add_plugin(TintShiftValue LogicalFunction nes-logical-operators TintShiftValueLogicalFunction.cpp) add_plugin(DivTintInt LogicalFunction nes-logical-operators DivTintIntLogicalFunction.cpp) add_plugin(DivTnumberTnumber LogicalFunction nes-logical-operators DivTnumberTnumberLogicalFunction.cpp) add_plugin(MulTintInt LogicalFunction nes-logical-operators MulTintIntLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TdistanceTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TdistanceTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..01517365af --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TdistanceTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TdistanceTintIntLogicalFunction::TdistanceTintIntLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction d) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(d)); +} + +DataType TdistanceTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TdistanceTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TdistanceTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TdistanceTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TdistanceTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TdistanceTintIntLogicalFunction::getType() const { return NAME; } + +bool TdistanceTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TdistanceTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TdistanceTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TdistanceTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTdistanceTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TdistanceTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TdistanceTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TintScaleValueLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TintScaleValueLogicalFunction.cpp new file mode 100644 index 0000000000..d51aadcdef --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TintScaleValueLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TintScaleValueLogicalFunction::TintScaleValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction width) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(width)); +} + +DataType TintScaleValueLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TintScaleValueLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TintScaleValueLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TintScaleValueLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TintScaleValueLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TintScaleValueLogicalFunction::getType() const { return NAME; } + +bool TintScaleValueLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TintScaleValueLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TintScaleValueLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TintScaleValueLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTintScaleValueLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TintScaleValueLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TintScaleValueLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TintShiftScaleValueLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TintShiftScaleValueLogicalFunction.cpp new file mode 100644 index 0000000000..b4096559fb --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TintShiftScaleValueLogicalFunction.cpp @@ -0,0 +1,108 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TintShiftScaleValueLogicalFunction::TintShiftScaleValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction shift, + LogicalFunction width) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(shift)); + parameters.push_back(std::move(width)); +} + +DataType TintShiftScaleValueLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TintShiftScaleValueLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TintShiftScaleValueLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TintShiftScaleValueLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TintShiftScaleValueLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TintShiftScaleValueLogicalFunction::getType() const { return NAME; } + +bool TintShiftScaleValueLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TintShiftScaleValueLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TintShiftScaleValueLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TintShiftScaleValueLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTintShiftScaleValueLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TintShiftScaleValueLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TintShiftScaleValueLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TintShiftValueLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TintShiftValueLogicalFunction.cpp new file mode 100644 index 0000000000..c540e6ea81 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TintShiftValueLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TintShiftValueLogicalFunction::TintShiftValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction shift) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(shift)); +} + +DataType TintShiftValueLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TintShiftValueLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TintShiftValueLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TintShiftValueLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TintShiftValueLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TintShiftValueLogicalFunction::getType() const { return NAME; } + +bool TintShiftValueLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TintShiftValueLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TintShiftValueLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TintShiftValueLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTintShiftValueLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TintShiftValueLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TintShiftValueLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TdistanceTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TdistanceTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..02d4ffe164 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TdistanceTintIntPhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tdistance_tint_int`. + * + * Per-event tdistance_tint_int: computes the temporal distance between a + * single-instant tint value and a constant integer. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TdistanceTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + TdistanceTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction dFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TintScaleValuePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TintScaleValuePhysicalFunction.hpp new file mode 100644 index 0000000000..e55e1d9ad3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TintScaleValuePhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tint_scale_value`. + * + * Per-event tint_scale_value: scales the value span of a single-instant tint + * to the given integer width. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TintScaleValuePhysicalFunction : public PhysicalFunctionConcept { +public: + TintScaleValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction widthFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TintShiftScaleValuePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TintShiftScaleValuePhysicalFunction.hpp new file mode 100644 index 0000000000..d6c7628c8c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TintShiftScaleValuePhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tint_shift_scale_value`. + * + * Per-event tint_shift_scale_value: shifts the value span of a single-instant + * tint by a constant integer and scales it to the given integer width. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TintShiftScaleValuePhysicalFunction : public PhysicalFunctionConcept { +public: + TintShiftScaleValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction shiftFunction, + PhysicalFunction widthFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TintShiftValuePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TintShiftValuePhysicalFunction.hpp new file mode 100644 index 0000000000..f12e6e7240 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TintShiftValuePhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tint_shift_value`. + * + * Per-event tint_shift_value: shifts the value span of a single-instant tint + * by a constant integer. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TintShiftValuePhysicalFunction : public PhysicalFunctionConcept { +public: + TintShiftValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction shiftFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 1b7168a2c2..5138cf9b1d 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -27,8 +27,12 @@ add_plugin(AddTfloatFloat PhysicalFunction nes-physical-operators AddTfloatFloat add_plugin(AddTintInt PhysicalFunction nes-physical-operators AddTintIntPhysicalFunction.cpp) add_plugin(AddTnumberTnumber PhysicalFunction nes-physical-operators AddTnumberTnumberPhysicalFunction.cpp) add_plugin(TdistanceTfloatFloat PhysicalFunction nes-physical-operators TdistanceTfloatFloatPhysicalFunction.cpp) +add_plugin(TdistanceTintInt PhysicalFunction nes-physical-operators TdistanceTintIntPhysicalFunction.cpp) add_plugin(TdistanceTnumberTnumber PhysicalFunction nes-physical-operators TdistanceTnumberTnumberPhysicalFunction.cpp) add_plugin(TemporalRound PhysicalFunction nes-physical-operators TemporalRoundPhysicalFunction.cpp) +add_plugin(TintScaleValue PhysicalFunction nes-physical-operators TintScaleValuePhysicalFunction.cpp) +add_plugin(TintShiftScaleValue PhysicalFunction nes-physical-operators TintShiftScaleValuePhysicalFunction.cpp) +add_plugin(TintShiftValue PhysicalFunction nes-physical-operators TintShiftValuePhysicalFunction.cpp) add_plugin(DivTintInt PhysicalFunction nes-physical-operators DivTintIntPhysicalFunction.cpp) add_plugin(DivTnumberTnumber PhysicalFunction nes-physical-operators DivTnumberTnumberPhysicalFunction.cpp) add_plugin(MulTintInt PhysicalFunction nes-physical-operators MulTintIntPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/TdistanceTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TdistanceTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..fc43b94327 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TdistanceTintIntPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TdistanceTintIntPhysicalFunction::TdistanceTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction dFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(dFunction)); +} + +VarVal TdistanceTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto d = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double d_val) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tdistance_tint_int(temp, static_cast(d_val)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, d); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTdistanceTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TdistanceTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TdistanceTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TintScaleValuePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TintScaleValuePhysicalFunction.cpp new file mode 100644 index 0000000000..aebbb9ed6b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TintScaleValuePhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TintScaleValuePhysicalFunction::TintScaleValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction widthFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(widthFunction)); +} + +VarVal TintScaleValuePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto width = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double width_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tint_scale_value(temp, static_cast(width_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, width); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTintScaleValuePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TintScaleValuePhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TintScaleValuePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TintShiftScaleValuePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TintShiftScaleValuePhysicalFunction.cpp new file mode 100644 index 0000000000..ff1780d328 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TintShiftScaleValuePhysicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TintShiftScaleValuePhysicalFunction::TintShiftScaleValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction shiftFunction, + PhysicalFunction widthFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(shiftFunction)); + parameterFunctions.push_back(std::move(widthFunction)); +} + +VarVal TintShiftScaleValuePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto shift = parameterValues[2].cast>(); + auto width = parameterValues[3].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double shift_d, double width_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tint_shift_scale_value(temp, static_cast(shift_d), static_cast(width_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, shift, width); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTintShiftScaleValuePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TintShiftScaleValuePhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TintShiftScaleValuePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TintShiftValuePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TintShiftValuePhysicalFunction.cpp new file mode 100644 index 0000000000..608e63b0f7 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TintShiftValuePhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TintShiftValuePhysicalFunction::TintShiftValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction shiftFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(shiftFunction)); +} + +VarVal TintShiftValuePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto shift = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double shift_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tint_shift_value(temp, static_cast(shift_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, shift); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTintShiftValuePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TintShiftValuePhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TintShiftValuePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index f41484aa70..4afbde6abd 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -501,6 +501,7 @@ SUB_TFLOAT_FLOAT: 'SUB_TFLOAT_FLOAT' | 'sub_tfloat_float'; SUB_TINT_INT: 'SUB_TINT_INT' | 'sub_tint_int'; SUB_TNUMBER_TNUMBER: 'SUB_TNUMBER_TNUMBER' | 'sub_tnumber_tnumber'; TDISTANCE_TFLOAT_FLOAT: 'TDISTANCE_TFLOAT_FLOAT' | 'tdistance_tfloat_float'; +TDISTANCE_TINT_INT: 'TDISTANCE_TINT_INT' | 'tdistance_tint_int'; TDISTANCE_TNUMBER_TNUMBER: 'TDISTANCE_TNUMBER_TNUMBER' | 'tdistance_tnumber_tnumber'; TEMPORAL_ROUND: 'TEMPORAL_ROUND' | 'temporal_round'; TFLOAT_CEIL: 'TFLOAT_CEIL' | 'tfloat_ceil'; @@ -513,6 +514,9 @@ TFLOAT_SHIFT_SCALE_VALUE: 'TFLOAT_SHIFT_SCALE_VALUE' | 'tfloat_shift_scale_value TFLOAT_SHIFT_VALUE: 'TFLOAT_SHIFT_VALUE' | 'tfloat_shift_value'; TFLOAT_SIN: 'TFLOAT_SIN' | 'tfloat_sin'; TFLOAT_TAN: 'TFLOAT_TAN' | 'tfloat_tan'; +TINT_SCALE_VALUE: 'TINT_SCALE_VALUE' | 'tint_scale_value'; +TINT_SHIFT_SCALE_VALUE: 'TINT_SHIFT_SCALE_VALUE' | 'tint_shift_scale_value'; +TINT_SHIFT_VALUE: 'TINT_SHIFT_VALUE' | 'tint_shift_value'; TNUMBER_ABS: 'TNUMBER_ABS' | 'tnumber_abs'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 0ed1f77265..cc8764f9be 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -82,6 +82,7 @@ #include #include #include +#include #include #include #include @@ -94,6 +95,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -1903,6 +1907,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TDISTANCE_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TDISTANCE_TINT_INT */ + case AntlrSQLLexer::TDISTANCE_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TDISTANCE_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TdistanceTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TDISTANCE_TINT_INT */ case AntlrSQLLexer::TDISTANCE_TNUMBER_TNUMBER: { @@ -1961,6 +1994,94 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TEMPORAL_ROUND */ + /* BEGIN CODEGEN PARSER GLUE: TINT_SCALE_VALUE */ + case AntlrSQLLexer::TINT_SCALE_VALUE: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TINT_SCALE_VALUE requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TintScaleValueLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TINT_SCALE_VALUE */ + /* BEGIN CODEGEN PARSER GLUE: TINT_SHIFT_SCALE_VALUE */ + case AntlrSQLLexer::TINT_SHIFT_SCALE_VALUE: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TINT_SHIFT_SCALE_VALUE requires exactly 4 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a3 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TintShiftScaleValueLogicalFunction(a0, a1, a2, a3)); + } + break; + /* END CODEGEN PARSER GLUE: TINT_SHIFT_SCALE_VALUE */ + /* BEGIN CODEGEN PARSER GLUE: TINT_SHIFT_VALUE */ + case AntlrSQLLexer::TINT_SHIFT_VALUE: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TINT_SHIFT_VALUE requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TintShiftValueLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TINT_SHIFT_VALUE */ default: /// Check if the function is a constructor for a datatype From 9be67595e06abffd285bc027f2af0ebb7deeaf41 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 06:12:05 +0200 Subject: [PATCH 11/86] feat(meos): add TFLOAT_TO_TINT and TINT_TO_TFLOAT type-conversion NES operators (W53) --- .../Meos/TfloatToTintLogicalFunction.hpp | 53 +++++++++ .../Meos/TintToTfloatLogicalFunction.hpp | 53 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../Meos/TfloatToTintLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/TintToTfloatLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/TfloatToTintPhysicalFunction.hpp | 42 ++++++++ .../Meos/TintToTfloatPhysicalFunction.hpp | 42 ++++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../Meos/TfloatToTintPhysicalFunction.cpp | 87 +++++++++++++++ .../Meos/TintToTfloatPhysicalFunction.cpp | 88 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 4 +- .../src/AntlrSQLQueryPlanCreator.cpp | 58 ++++++++++ 12 files changed, 634 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatToTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TintToTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatToTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TintToTfloatLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatToTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TintToTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatToTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TintToTfloatPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TfloatToTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatToTintLogicalFunction.hpp new file mode 100644 index 0000000000..0d47f35168 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatToTintLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_to_tint: converts a single-instant tfloat to tint, returns FLOAT64. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_to_tint`. Takes (value:FLOAT64, ts:UINT64), constructs a single-instant + * temporal float, truncates to integer, and returns FLOAT64. + */ +class TfloatToTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatToTint"; + + TfloatToTintLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TintToTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TintToTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..6de528f985 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TintToTfloatLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tint_to_tfloat: converts a single-instant tint to tfloat, returns FLOAT64. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tint_to_tfloat`. Takes (value:FLOAT64, ts:UINT64), constructs a single-instant + * temporal integer, promotes to float, and returns FLOAT64. + */ +class TintToTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TintToTfloat"; + + TintToTfloatLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 49cd3f9231..4657c2f4fb 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -47,4 +47,6 @@ add_plugin(TfloatShiftScaleValue LogicalFunction nes-logical-operators TfloatShi add_plugin(TfloatShiftValue LogicalFunction nes-logical-operators TfloatShiftValueLogicalFunction.cpp) add_plugin(TfloatSin LogicalFunction nes-logical-operators TfloatSinLogicalFunction.cpp) add_plugin(TfloatTan LogicalFunction nes-logical-operators TfloatTanLogicalFunction.cpp) +add_plugin(TfloatToTint LogicalFunction nes-logical-operators TfloatToTintLogicalFunction.cpp) +add_plugin(TintToTfloat LogicalFunction nes-logical-operators TintToTfloatLogicalFunction.cpp) add_plugin(TnumberAbs LogicalFunction nes-logical-operators TnumberAbsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TfloatToTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatToTintLogicalFunction.cpp new file mode 100644 index 0000000000..63bf97d316 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatToTintLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatToTintLogicalFunction::TfloatToTintLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TfloatToTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatToTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatToTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatToTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TfloatToTintLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatToTintLogicalFunction::getType() const { return NAME; } + +bool TfloatToTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatToTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatToTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatToTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatToTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TfloatToTintLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TfloatToTintLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TintToTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TintToTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..08c9e80ad4 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TintToTfloatLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TintToTfloatLogicalFunction::TintToTfloatLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TintToTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TintToTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TintToTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TintToTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TintToTfloatLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TintToTfloatLogicalFunction::getType() const { return NAME; } + +bool TintToTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TintToTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TintToTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TintToTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTintToTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TintToTfloatLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TintToTfloatLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatToTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatToTintPhysicalFunction.hpp new file mode 100644 index 0000000000..48c2bd2f92 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatToTintPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_to_tint`. + * + * Per-event tfloat_to_tint: single-instant tfloat converted to tint, result extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatToTintPhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatToTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TintToTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TintToTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..c338179d9b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TintToTfloatPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tint_to_tfloat`. + * + * Per-event tint_to_tfloat: single-instant tint promoted to tfloat, result extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TintToTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TintToTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 5138cf9b1d..68c2b6a81c 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -46,5 +46,7 @@ add_plugin(TfloatShiftScaleValue PhysicalFunction nes-physical-operators TfloatS add_plugin(TfloatShiftValue PhysicalFunction nes-physical-operators TfloatShiftValuePhysicalFunction.cpp) add_plugin(TfloatSin PhysicalFunction nes-physical-operators TfloatSinPhysicalFunction.cpp) add_plugin(TfloatTan PhysicalFunction nes-physical-operators TfloatTanPhysicalFunction.cpp) +add_plugin(TfloatToTint PhysicalFunction nes-physical-operators TfloatToTintPhysicalFunction.cpp) +add_plugin(TintToTfloat PhysicalFunction nes-physical-operators TintToTfloatPhysicalFunction.cpp) add_plugin(TnumberAbs PhysicalFunction nes-physical-operators TnumberAbsPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TfloatToTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatToTintPhysicalFunction.cpp new file mode 100644 index 0000000000..1c2f2cca6d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatToTintPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatToTintPhysicalFunction::TfloatToTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TfloatToTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_to_tint(temp); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatToTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TfloatToTintPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TfloatToTintPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TintToTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TintToTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..23eb9eb5dc --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TintToTfloatPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TintToTfloatPhysicalFunction::TintToTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TintToTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), + MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tint_to_tfloat(temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTintToTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TintToTfloatPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TintToTfloatPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 4afbde6abd..904df4a954 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -514,9 +514,11 @@ TFLOAT_SHIFT_SCALE_VALUE: 'TFLOAT_SHIFT_SCALE_VALUE' | 'tfloat_shift_scale_value TFLOAT_SHIFT_VALUE: 'TFLOAT_SHIFT_VALUE' | 'tfloat_shift_value'; TFLOAT_SIN: 'TFLOAT_SIN' | 'tfloat_sin'; TFLOAT_TAN: 'TFLOAT_TAN' | 'tfloat_tan'; +TFLOAT_TO_TINT: 'TFLOAT_TO_TINT' | 'tfloat_to_tint'; TINT_SCALE_VALUE: 'TINT_SCALE_VALUE' | 'tint_scale_value'; TINT_SHIFT_SCALE_VALUE: 'TINT_SHIFT_SCALE_VALUE' | 'tint_shift_scale_value'; TINT_SHIFT_VALUE: 'TINT_SHIFT_VALUE' | 'tint_shift_value'; +TINT_TO_TFLOAT: 'TINT_TO_TFLOAT' | 'tint_to_tfloat'; TNUMBER_ABS: 'TNUMBER_ABS' | 'tnumber_abs'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index cc8764f9be..ffecad8e62 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -95,9 +95,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -1301,6 +1303,34 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TFLOAT_TAN */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_TO_TINT */ + case AntlrSQLLexer::TFLOAT_TO_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TFLOAT_TO_TINT requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatToTintLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_TO_TINT */ /* BEGIN CODEGEN PARSER GLUE: TFLOAT_CEIL */ case AntlrSQLLexer::TFLOAT_CEIL: { @@ -2082,6 +2112,34 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TINT_SHIFT_VALUE */ + /* BEGIN CODEGEN PARSER GLUE: TINT_TO_TFLOAT */ + case AntlrSQLLexer::TINT_TO_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TINT_TO_TFLOAT requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TintToTfloatLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TINT_TO_TFLOAT */ default: /// Check if the function is a constructor for a datatype From e53bbc132459a4902fc6b1550da98ce2787188a8 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 06:18:42 +0200 Subject: [PATCH 12/86] feat(meos): add tbigint type-conversion NES operators TBIGINT_TO_TINT, TBIGINT_TO_TFLOAT, TINT_TO_TBIGINT, TFLOAT_TO_TBIGINT (W54) --- .../Meos/TbigintToTfloatLogicalFunction.hpp | 53 ++++++++ .../Meos/TbigintToTintLogicalFunction.hpp | 53 ++++++++ .../Meos/TfloatToTbigintLogicalFunction.hpp | 53 ++++++++ .../Meos/TintToTbigintLogicalFunction.hpp | 53 ++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/TbigintToTfloatLogicalFunction.cpp | 102 +++++++++++++++ .../Meos/TbigintToTintLogicalFunction.cpp | 102 +++++++++++++++ .../Meos/TfloatToTbigintLogicalFunction.cpp | 102 +++++++++++++++ .../Meos/TintToTbigintLogicalFunction.cpp | 102 +++++++++++++++ .../Meos/TbigintToTfloatPhysicalFunction.hpp | 42 +++++++ .../Meos/TbigintToTintPhysicalFunction.hpp | 42 +++++++ .../Meos/TfloatToTbigintPhysicalFunction.hpp | 42 +++++++ .../Meos/TintToTbigintPhysicalFunction.hpp | 42 +++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/TbigintToTfloatPhysicalFunction.cpp | 87 +++++++++++++ .../Meos/TbigintToTintPhysicalFunction.cpp | 87 +++++++++++++ .../Meos/TfloatToTbigintPhysicalFunction.cpp | 87 +++++++++++++ .../Meos/TintToTbigintPhysicalFunction.cpp | 87 +++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 116 ++++++++++++++++++ 20 files changed, 1265 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TbigintToTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TbigintToTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatToTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TintToTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TbigintToTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TbigintToTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatToTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TintToTbigintLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TbigintToTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TbigintToTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatToTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TintToTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TbigintToTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TbigintToTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatToTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TintToTbigintPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TbigintToTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TbigintToTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..aafccec021 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TbigintToTfloatLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tbigint_to_tfloat: converts a single-instant tbigint to tfloat, returns FLOAT64. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tbigint_to_tfloat`. Takes (value:FLOAT64, ts:UINT64), constructs a single-instant + * temporal bigint, widens to float, and returns FLOAT64. + */ +class TbigintToTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TbigintToTfloat"; + + TbigintToTfloatLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TbigintToTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TbigintToTintLogicalFunction.hpp new file mode 100644 index 0000000000..78e9cbb7d3 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TbigintToTintLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tbigint_to_tint: converts a single-instant tbigint to tint, returns FLOAT64. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tbigint_to_tint`. Takes (value:FLOAT64, ts:UINT64), constructs a single-instant + * temporal bigint, narrows to integer, and returns FLOAT64. + */ +class TbigintToTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TbigintToTint"; + + TbigintToTintLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TfloatToTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatToTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..67a04b12b5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatToTbigintLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_to_tbigint: converts a single-instant tfloat to tbigint, returns FLOAT64. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_to_tbigint`. Takes (value:FLOAT64, ts:UINT64), constructs a single-instant + * temporal float, truncates to bigint, and returns FLOAT64. + */ +class TfloatToTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatToTbigint"; + + TfloatToTbigintLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TintToTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TintToTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..f9460e7edd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TintToTbigintLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tint_to_tbigint: converts a single-instant tint to tbigint, returns FLOAT64. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tint_to_tbigint`. Takes (value:FLOAT64, ts:UINT64), constructs a single-instant + * temporal integer, widens to bigint, and returns FLOAT64. + */ +class TintToTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TintToTbigint"; + + TintToTbigintLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 4657c2f4fb..50e5392a95 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -47,6 +47,10 @@ add_plugin(TfloatShiftScaleValue LogicalFunction nes-logical-operators TfloatShi add_plugin(TfloatShiftValue LogicalFunction nes-logical-operators TfloatShiftValueLogicalFunction.cpp) add_plugin(TfloatSin LogicalFunction nes-logical-operators TfloatSinLogicalFunction.cpp) add_plugin(TfloatTan LogicalFunction nes-logical-operators TfloatTanLogicalFunction.cpp) +add_plugin(TbigintToTfloat LogicalFunction nes-logical-operators TbigintToTfloatLogicalFunction.cpp) +add_plugin(TbigintToTint LogicalFunction nes-logical-operators TbigintToTintLogicalFunction.cpp) +add_plugin(TfloatToTbigint LogicalFunction nes-logical-operators TfloatToTbigintLogicalFunction.cpp) add_plugin(TfloatToTint LogicalFunction nes-logical-operators TfloatToTintLogicalFunction.cpp) +add_plugin(TintToTbigint LogicalFunction nes-logical-operators TintToTbigintLogicalFunction.cpp) add_plugin(TintToTfloat LogicalFunction nes-logical-operators TintToTfloatLogicalFunction.cpp) add_plugin(TnumberAbs LogicalFunction nes-logical-operators TnumberAbsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TbigintToTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TbigintToTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..65b2a6cefd --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TbigintToTfloatLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TbigintToTfloatLogicalFunction::TbigintToTfloatLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TbigintToTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TbigintToTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TbigintToTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TbigintToTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TbigintToTfloatLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TbigintToTfloatLogicalFunction::getType() const { return NAME; } + +bool TbigintToTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TbigintToTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TbigintToTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TbigintToTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTbigintToTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TbigintToTfloatLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TbigintToTfloatLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TbigintToTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TbigintToTintLogicalFunction.cpp new file mode 100644 index 0000000000..312df7d30a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TbigintToTintLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TbigintToTintLogicalFunction::TbigintToTintLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TbigintToTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TbigintToTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TbigintToTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TbigintToTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TbigintToTintLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TbigintToTintLogicalFunction::getType() const { return NAME; } + +bool TbigintToTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TbigintToTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TbigintToTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TbigintToTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTbigintToTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TbigintToTintLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TbigintToTintLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TfloatToTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatToTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..b86add8d10 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatToTbigintLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatToTbigintLogicalFunction::TfloatToTbigintLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TfloatToTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatToTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatToTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatToTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TfloatToTbigintLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatToTbigintLogicalFunction::getType() const { return NAME; } + +bool TfloatToTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatToTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatToTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatToTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatToTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TfloatToTbigintLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TfloatToTbigintLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TintToTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TintToTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..681eb6857d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TintToTbigintLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TintToTbigintLogicalFunction::TintToTbigintLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TintToTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TintToTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TintToTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TintToTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TintToTbigintLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TintToTbigintLogicalFunction::getType() const { return NAME; } + +bool TintToTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TintToTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TintToTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TintToTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTintToTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TintToTbigintLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TintToTbigintLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TbigintToTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TbigintToTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..a59b288ff5 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TbigintToTfloatPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tbigint_to_tfloat`. + * + * Per-event tbigint_to_tfloat: single-instant tbigint converted to tfloat, result extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TbigintToTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TbigintToTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TbigintToTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TbigintToTintPhysicalFunction.hpp new file mode 100644 index 0000000000..a122dcf560 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TbigintToTintPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tbigint_to_tint`. + * + * Per-event tbigint_to_tint: single-instant tbigint converted to tint, result extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TbigintToTintPhysicalFunction : public PhysicalFunctionConcept { +public: + TbigintToTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatToTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatToTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..0a6d8397fb --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatToTbigintPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_to_tbigint`. + * + * Per-event tfloat_to_tbigint: single-instant tfloat converted to tbigint, result extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatToTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatToTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TintToTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TintToTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..0d761ed1a8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TintToTbigintPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tint_to_tbigint`. + * + * Per-event tint_to_tbigint: single-instant tint converted to tbigint, result extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TintToTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + TintToTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 68c2b6a81c..3b10b0af05 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -46,7 +46,11 @@ add_plugin(TfloatShiftScaleValue PhysicalFunction nes-physical-operators TfloatS add_plugin(TfloatShiftValue PhysicalFunction nes-physical-operators TfloatShiftValuePhysicalFunction.cpp) add_plugin(TfloatSin PhysicalFunction nes-physical-operators TfloatSinPhysicalFunction.cpp) add_plugin(TfloatTan PhysicalFunction nes-physical-operators TfloatTanPhysicalFunction.cpp) +add_plugin(TbigintToTfloat PhysicalFunction nes-physical-operators TbigintToTfloatPhysicalFunction.cpp) +add_plugin(TbigintToTint PhysicalFunction nes-physical-operators TbigintToTintPhysicalFunction.cpp) +add_plugin(TfloatToTbigint PhysicalFunction nes-physical-operators TfloatToTbigintPhysicalFunction.cpp) add_plugin(TfloatToTint PhysicalFunction nes-physical-operators TfloatToTintPhysicalFunction.cpp) +add_plugin(TintToTbigint PhysicalFunction nes-physical-operators TintToTbigintPhysicalFunction.cpp) add_plugin(TintToTfloat PhysicalFunction nes-physical-operators TintToTfloatPhysicalFunction.cpp) add_plugin(TnumberAbs PhysicalFunction nes-physical-operators TnumberAbsPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TbigintToTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TbigintToTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..a8ba3a08b4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TbigintToTfloatPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TbigintToTfloatPhysicalFunction::TbigintToTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TbigintToTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tbigint_to_tfloat(temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTbigintToTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TbigintToTfloatPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TbigintToTfloatPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TbigintToTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TbigintToTintPhysicalFunction.cpp new file mode 100644 index 0000000000..32a231a74a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TbigintToTintPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TbigintToTintPhysicalFunction::TbigintToTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TbigintToTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tbigint_to_tint(temp); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTbigintToTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TbigintToTintPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TbigintToTintPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TfloatToTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatToTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..9549684d2b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatToTbigintPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatToTbigintPhysicalFunction::TfloatToTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TfloatToTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_to_tbigint(temp); + free(temp); + if (!res) return 0.0; + double r = static_cast(tbigint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatToTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TfloatToTbigintPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TfloatToTbigintPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TintToTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TintToTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..36a685a163 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TintToTbigintPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TintToTbigintPhysicalFunction::TintToTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TintToTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tint_to_tbigint(temp); + free(temp); + if (!res) return 0.0; + double r = static_cast(tbigint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTintToTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TintToTbigintPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TintToTbigintPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 904df4a954..3c0413fb45 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -500,6 +500,8 @@ MUL_TNUMBER_TNUMBER: 'MUL_TNUMBER_TNUMBER' | 'mul_tnumber_tnumber'; SUB_TFLOAT_FLOAT: 'SUB_TFLOAT_FLOAT' | 'sub_tfloat_float'; SUB_TINT_INT: 'SUB_TINT_INT' | 'sub_tint_int'; SUB_TNUMBER_TNUMBER: 'SUB_TNUMBER_TNUMBER' | 'sub_tnumber_tnumber'; +TBIGINT_TO_TFLOAT: 'TBIGINT_TO_TFLOAT' | 'tbigint_to_tfloat'; +TBIGINT_TO_TINT: 'TBIGINT_TO_TINT' | 'tbigint_to_tint'; TDISTANCE_TFLOAT_FLOAT: 'TDISTANCE_TFLOAT_FLOAT' | 'tdistance_tfloat_float'; TDISTANCE_TINT_INT: 'TDISTANCE_TINT_INT' | 'tdistance_tint_int'; TDISTANCE_TNUMBER_TNUMBER: 'TDISTANCE_TNUMBER_TNUMBER' | 'tdistance_tnumber_tnumber'; @@ -514,10 +516,12 @@ TFLOAT_SHIFT_SCALE_VALUE: 'TFLOAT_SHIFT_SCALE_VALUE' | 'tfloat_shift_scale_value TFLOAT_SHIFT_VALUE: 'TFLOAT_SHIFT_VALUE' | 'tfloat_shift_value'; TFLOAT_SIN: 'TFLOAT_SIN' | 'tfloat_sin'; TFLOAT_TAN: 'TFLOAT_TAN' | 'tfloat_tan'; +TFLOAT_TO_TBIGINT: 'TFLOAT_TO_TBIGINT' | 'tfloat_to_tbigint'; TFLOAT_TO_TINT: 'TFLOAT_TO_TINT' | 'tfloat_to_tint'; TINT_SCALE_VALUE: 'TINT_SCALE_VALUE' | 'tint_scale_value'; TINT_SHIFT_SCALE_VALUE: 'TINT_SHIFT_SCALE_VALUE' | 'tint_shift_scale_value'; TINT_SHIFT_VALUE: 'TINT_SHIFT_VALUE' | 'tint_shift_value'; +TINT_TO_TBIGINT: 'TINT_TO_TBIGINT' | 'tint_to_tbigint'; TINT_TO_TFLOAT: 'TINT_TO_TFLOAT' | 'tint_to_tfloat'; TNUMBER_ABS: 'TNUMBER_ABS' | 'tnumber_abs'; WATERMARK: 'WATERMARK' | 'watermark'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index ffecad8e62..427782a1ea 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -81,6 +81,8 @@ #include #include #include +#include +#include #include #include #include @@ -95,10 +97,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -1303,6 +1307,34 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TFLOAT_TAN */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_TO_TBIGINT */ + case AntlrSQLLexer::TFLOAT_TO_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TFLOAT_TO_TBIGINT requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatToTbigintLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_TO_TBIGINT */ /* BEGIN CODEGEN PARSER GLUE: TFLOAT_TO_TINT */ case AntlrSQLLexer::TFLOAT_TO_TINT: { @@ -1908,6 +1940,62 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: SUB_TNUMBER_TNUMBER */ + /* BEGIN CODEGEN PARSER GLUE: TBIGINT_TO_TFLOAT */ + case AntlrSQLLexer::TBIGINT_TO_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TBIGINT_TO_TFLOAT requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TbigintToTfloatLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TBIGINT_TO_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TBIGINT_TO_TINT */ + case AntlrSQLLexer::TBIGINT_TO_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TBIGINT_TO_TINT requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TbigintToTintLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TBIGINT_TO_TINT */ case AntlrSQLLexer::TDISTANCE_TFLOAT_FLOAT: { @@ -2112,6 +2200,34 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TINT_SHIFT_VALUE */ + /* BEGIN CODEGEN PARSER GLUE: TINT_TO_TBIGINT */ + case AntlrSQLLexer::TINT_TO_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TINT_TO_TBIGINT requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TintToTbigintLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TINT_TO_TBIGINT */ /* BEGIN CODEGEN PARSER GLUE: TINT_TO_TFLOAT */ case AntlrSQLLexer::TINT_TO_TFLOAT: { From 677ea809cd9deeb98df40015f74705a545669853 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 06:24:39 +0200 Subject: [PATCH 13/86] feat(meos): add ADD/SUB/MUL/DIV_TBIGINT_BIGINT NES operators (W55) --- .../Meos/AddTbigintBigintLogicalFunction.hpp | 54 ++++++++ .../Meos/DivTbigintBigintLogicalFunction.hpp | 54 ++++++++ .../Meos/MulTbigintBigintLogicalFunction.hpp | 54 ++++++++ .../Meos/SubTbigintBigintLogicalFunction.hpp | 54 ++++++++ .../Meos/AddTbigintBigintLogicalFunction.cpp | 105 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/DivTbigintBigintLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/MulTbigintBigintLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/SubTbigintBigintLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/AddTbigintBigintPhysicalFunction.hpp | 43 +++++++ .../Meos/DivTbigintBigintPhysicalFunction.hpp | 43 +++++++ .../Meos/MulTbigintBigintPhysicalFunction.hpp | 43 +++++++ .../Meos/SubTbigintBigintPhysicalFunction.hpp | 43 +++++++ .../Meos/AddTbigintBigintPhysicalFunction.cpp | 92 ++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/DivTbigintBigintPhysicalFunction.cpp | 92 ++++++++++++++ .../Meos/MulTbigintBigintPhysicalFunction.cpp | 92 ++++++++++++++ .../Meos/SubTbigintBigintPhysicalFunction.cpp | 92 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 120 ++++++++++++++++++ 20 files changed, 1309 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AddTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/DivTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/MulTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/SubTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AddTbigintBigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/DivTbigintBigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/MulTbigintBigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/SubTbigintBigintLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AddTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/DivTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/MulTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/SubTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AddTbigintBigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/DivTbigintBigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/MulTbigintBigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/SubTbigintBigintPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AddTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AddTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..c97f49cb16 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AddTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event add_tbigint_bigint: adds a constant int64 to a single-instant tbigint value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `add_tbigint_bigint`. Takes (value:FLOAT64, ts:UINT64, addend:FLOAT64→int64), + * constructs a single-instant temporal, applies the addition, and returns FLOAT64. + */ +class AddTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AddTbigintBigint"; + + AddTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction addend); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/DivTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/DivTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..48d916f76d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/DivTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event div_tbigint_bigint: divides a single-instant tbigint value by a constant int64. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `div_tbigint_bigint`. Takes (value:FLOAT64, ts:UINT64, divisor:FLOAT64→int64), + * constructs a single-instant temporal, applies the division, and returns FLOAT64. + */ +class DivTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "DivTbigintBigint"; + + DivTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction divisor); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/MulTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/MulTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..ff857a8773 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/MulTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event mul_tbigint_bigint: multiplies a single-instant tbigint value by a constant int64. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `mul_tbigint_bigint`. Takes (value:FLOAT64, ts:UINT64, factor:FLOAT64→int64), + * constructs a single-instant temporal, applies the multiplication, and returns FLOAT64. + */ +class MulTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "MulTbigintBigint"; + + MulTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction factor); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/SubTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/SubTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..c1ff3f9a15 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/SubTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event sub_tbigint_bigint: subtracts a constant int64 from a single-instant tbigint value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `sub_tbigint_bigint`. Takes (value:FLOAT64, ts:UINT64, subtrahend:FLOAT64→int64), + * constructs a single-instant temporal, applies the subtraction, and returns FLOAT64. + */ +class SubTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "SubTbigintBigint"; + + SubTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction subtrahend); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AddTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AddTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..68d4e06d74 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AddTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AddTbigintBigintLogicalFunction::AddTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction addend) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(addend)); +} + +DataType AddTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AddTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AddTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AddTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AddTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AddTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool AddTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AddTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AddTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AddTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAddTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AddTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AddTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 50e5392a95..58a9c60a18 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -25,6 +25,7 @@ add_plugin(TfloatFloor LogicalFunction nes-logical-operators TfloatFloorLogicalF add_plugin(TfloatRadians LogicalFunction nes-logical-operators TfloatRadiansLogicalFunction.cpp) add_plugin(TfloatScaleValue LogicalFunction nes-logical-operators TfloatScaleValueLogicalFunction.cpp) add_plugin(AddTfloatFloat LogicalFunction nes-logical-operators AddTfloatFloatLogicalFunction.cpp) +add_plugin(AddTbigintBigint LogicalFunction nes-logical-operators AddTbigintBigintLogicalFunction.cpp) add_plugin(AddTintInt LogicalFunction nes-logical-operators AddTintIntLogicalFunction.cpp) add_plugin(AddTnumberTnumber LogicalFunction nes-logical-operators AddTnumberTnumberLogicalFunction.cpp) add_plugin(TdistanceTfloatFloat LogicalFunction nes-logical-operators TdistanceTfloatFloatLogicalFunction.cpp) @@ -34,10 +35,13 @@ add_plugin(TemporalRound LogicalFunction nes-logical-operators TemporalRoundLogi add_plugin(TintScaleValue LogicalFunction nes-logical-operators TintScaleValueLogicalFunction.cpp) add_plugin(TintShiftScaleValue LogicalFunction nes-logical-operators TintShiftScaleValueLogicalFunction.cpp) add_plugin(TintShiftValue LogicalFunction nes-logical-operators TintShiftValueLogicalFunction.cpp) +add_plugin(DivTbigintBigint LogicalFunction nes-logical-operators DivTbigintBigintLogicalFunction.cpp) add_plugin(DivTintInt LogicalFunction nes-logical-operators DivTintIntLogicalFunction.cpp) add_plugin(DivTnumberTnumber LogicalFunction nes-logical-operators DivTnumberTnumberLogicalFunction.cpp) +add_plugin(MulTbigintBigint LogicalFunction nes-logical-operators MulTbigintBigintLogicalFunction.cpp) add_plugin(MulTintInt LogicalFunction nes-logical-operators MulTintIntLogicalFunction.cpp) add_plugin(MulTnumberTnumber LogicalFunction nes-logical-operators MulTnumberTnumberLogicalFunction.cpp) +add_plugin(SubTbigintBigint LogicalFunction nes-logical-operators SubTbigintBigintLogicalFunction.cpp) add_plugin(SubTintInt LogicalFunction nes-logical-operators SubTintIntLogicalFunction.cpp) add_plugin(SubTnumberTnumber LogicalFunction nes-logical-operators SubTnumberTnumberLogicalFunction.cpp) add_plugin(DivTfloatFloat LogicalFunction nes-logical-operators DivTfloatFloatLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/DivTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/DivTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..3f200be7c9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/DivTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +DivTbigintBigintLogicalFunction::DivTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction divisor) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(divisor)); +} + +DataType DivTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction DivTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector DivTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction DivTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "DivTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view DivTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool DivTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string DivTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction DivTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction DivTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterDivTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "DivTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return DivTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/MulTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/MulTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..0d1e68e0d1 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/MulTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +MulTbigintBigintLogicalFunction::MulTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction factor) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(factor)); +} + +DataType MulTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction MulTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector MulTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction MulTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "MulTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view MulTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool MulTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string MulTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction MulTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction MulTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterMulTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "MulTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return MulTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/SubTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/SubTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..ba377c8c8a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/SubTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +SubTbigintBigintLogicalFunction::SubTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction subtrahend) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(subtrahend)); +} + +DataType SubTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction SubTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector SubTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction SubTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "SubTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view SubTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool SubTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string SubTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction SubTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction SubTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterSubTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "SubTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return SubTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AddTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AddTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..86f61b764c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AddTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `add_tbigint_bigint`. + * + * Per-event add_tbigint_bigint: adds a constant int64 to a single-instant tbigint value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AddTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AddTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction addendFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/DivTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/DivTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..aafdd6ad39 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/DivTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `div_tbigint_bigint`. + * + * Per-event div_tbigint_bigint: divides a single-instant tbigint value by a constant int64. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class DivTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + DivTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction divisorFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/MulTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/MulTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..3736f42e2d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/MulTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `mul_tbigint_bigint`. + * + * Per-event mul_tbigint_bigint: multiplies a single-instant tbigint value by a constant int64. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class MulTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + MulTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction factorFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/SubTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/SubTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..5e42e74482 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/SubTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `sub_tbigint_bigint`. + * + * Per-event sub_tbigint_bigint: subtracts a constant int64 from a single-instant tbigint value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class SubTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + SubTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction subtrahendFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AddTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AddTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..0744733c6f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AddTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AddTbigintBigintPhysicalFunction::AddTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction addendFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(addendFunction)); +} + +VarVal AddTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto addend = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double addend_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), + MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = add_tbigint_bigint(temp, static_cast(addend_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tbigint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, addend); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAddTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AddTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AddTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 3b10b0af05..96feed49a1 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -24,6 +24,7 @@ add_plugin(TfloatFloor PhysicalFunction nes-physical-operators TfloatFloorPhysic add_plugin(TfloatRadians PhysicalFunction nes-physical-operators TfloatRadiansPhysicalFunction.cpp) add_plugin(TfloatScaleValue PhysicalFunction nes-physical-operators TfloatScaleValuePhysicalFunction.cpp) add_plugin(AddTfloatFloat PhysicalFunction nes-physical-operators AddTfloatFloatPhysicalFunction.cpp) +add_plugin(AddTbigintBigint PhysicalFunction nes-physical-operators AddTbigintBigintPhysicalFunction.cpp) add_plugin(AddTintInt PhysicalFunction nes-physical-operators AddTintIntPhysicalFunction.cpp) add_plugin(AddTnumberTnumber PhysicalFunction nes-physical-operators AddTnumberTnumberPhysicalFunction.cpp) add_plugin(TdistanceTfloatFloat PhysicalFunction nes-physical-operators TdistanceTfloatFloatPhysicalFunction.cpp) @@ -33,10 +34,13 @@ add_plugin(TemporalRound PhysicalFunction nes-physical-operators TemporalRoundPh add_plugin(TintScaleValue PhysicalFunction nes-physical-operators TintScaleValuePhysicalFunction.cpp) add_plugin(TintShiftScaleValue PhysicalFunction nes-physical-operators TintShiftScaleValuePhysicalFunction.cpp) add_plugin(TintShiftValue PhysicalFunction nes-physical-operators TintShiftValuePhysicalFunction.cpp) +add_plugin(DivTbigintBigint PhysicalFunction nes-physical-operators DivTbigintBigintPhysicalFunction.cpp) add_plugin(DivTintInt PhysicalFunction nes-physical-operators DivTintIntPhysicalFunction.cpp) add_plugin(DivTnumberTnumber PhysicalFunction nes-physical-operators DivTnumberTnumberPhysicalFunction.cpp) +add_plugin(MulTbigintBigint PhysicalFunction nes-physical-operators MulTbigintBigintPhysicalFunction.cpp) add_plugin(MulTintInt PhysicalFunction nes-physical-operators MulTintIntPhysicalFunction.cpp) add_plugin(MulTnumberTnumber PhysicalFunction nes-physical-operators MulTnumberTnumberPhysicalFunction.cpp) +add_plugin(SubTbigintBigint PhysicalFunction nes-physical-operators SubTbigintBigintPhysicalFunction.cpp) add_plugin(SubTintInt PhysicalFunction nes-physical-operators SubTintIntPhysicalFunction.cpp) add_plugin(SubTnumberTnumber PhysicalFunction nes-physical-operators SubTnumberTnumberPhysicalFunction.cpp) add_plugin(DivTfloatFloat PhysicalFunction nes-physical-operators DivTfloatFloatPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/DivTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/DivTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..381188aedf --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/DivTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +DivTbigintBigintPhysicalFunction::DivTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction divisorFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(divisorFunction)); +} + +VarVal DivTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto divisor = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double divisor_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), + MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = div_tbigint_bigint(temp, static_cast(divisor_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tbigint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, divisor); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterDivTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "DivTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return DivTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/MulTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/MulTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..b99b8a6441 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/MulTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +MulTbigintBigintPhysicalFunction::MulTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction factorFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(factorFunction)); +} + +VarVal MulTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto factor = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double factor_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), + MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = mul_tbigint_bigint(temp, static_cast(factor_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tbigint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, factor); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterMulTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "MulTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return MulTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/SubTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/SubTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..f625c29498 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/SubTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +SubTbigintBigintPhysicalFunction::SubTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction subtrahendFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(subtrahendFunction)); +} + +VarVal SubTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto subtrahend = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double subtrahend_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), + MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = sub_tbigint_bigint(temp, static_cast(subtrahend_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tbigint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, subtrahend); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterSubTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "SubTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return SubTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 3c0413fb45..390a9bf826 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -488,15 +488,19 @@ TEMPORAL_AINTERSECTS_GEOMETRY: 'TEMPORAL_AINTERSECTS_GEOMETRY' | 'temporal_ainte TEMPORAL_ECONTAINS_GEOMETRY: 'TEMPORAL_ECONTAINS_GEOMETRY' | 'temporal_econtains_geometry'; EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; TGEO_AT_STBOX: 'TGEO_AT_STBOX' | 'tgeo_at_stbox'; +ADD_TBIGINT_BIGINT: 'ADD_TBIGINT_BIGINT' | 'add_tbigint_bigint'; ADD_TFLOAT_FLOAT: 'ADD_TFLOAT_FLOAT' | 'add_tfloat_float'; ADD_TINT_INT: 'ADD_TINT_INT' | 'add_tint_int'; ADD_TNUMBER_TNUMBER: 'ADD_TNUMBER_TNUMBER' | 'add_tnumber_tnumber'; +DIV_TBIGINT_BIGINT: 'DIV_TBIGINT_BIGINT' | 'div_tbigint_bigint'; DIV_TFLOAT_FLOAT: 'DIV_TFLOAT_FLOAT' | 'div_tfloat_float'; DIV_TINT_INT: 'DIV_TINT_INT' | 'div_tint_int'; DIV_TNUMBER_TNUMBER: 'DIV_TNUMBER_TNUMBER' | 'div_tnumber_tnumber'; +MUL_TBIGINT_BIGINT: 'MUL_TBIGINT_BIGINT' | 'mul_tbigint_bigint'; MUL_TFLOAT_FLOAT: 'MUL_TFLOAT_FLOAT' | 'mul_tfloat_float'; MUL_TINT_INT: 'MUL_TINT_INT' | 'mul_tint_int'; MUL_TNUMBER_TNUMBER: 'MUL_TNUMBER_TNUMBER' | 'mul_tnumber_tnumber'; +SUB_TBIGINT_BIGINT: 'SUB_TBIGINT_BIGINT' | 'sub_tbigint_bigint'; SUB_TFLOAT_FLOAT: 'SUB_TFLOAT_FLOAT' | 'sub_tfloat_float'; SUB_TINT_INT: 'SUB_TINT_INT' | 'sub_tint_int'; SUB_TNUMBER_TNUMBER: 'SUB_TNUMBER_TNUMBER' | 'sub_tnumber_tnumber'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 427782a1ea..065bc99553 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -69,15 +69,19 @@ #include #include #include +#include #include #include #include +#include #include #include #include +#include #include #include #include +#include #include #include #include @@ -1707,6 +1711,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: SUB_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ADD_TBIGINT_BIGINT */ + case AntlrSQLLexer::ADD_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ADD_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AddTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ADD_TBIGINT_BIGINT */ case AntlrSQLLexer::ADD_TINT_INT: { @@ -1736,6 +1769,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: ADD_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: DIV_TBIGINT_BIGINT */ + case AntlrSQLLexer::DIV_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("DIV_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(DivTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: DIV_TBIGINT_BIGINT */ case AntlrSQLLexer::DIV_TINT_INT: { @@ -1765,6 +1827,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: DIV_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: MUL_TBIGINT_BIGINT */ + case AntlrSQLLexer::MUL_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("MUL_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(MulTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: MUL_TBIGINT_BIGINT */ case AntlrSQLLexer::MUL_TINT_INT: { @@ -1794,6 +1885,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: MUL_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: SUB_TBIGINT_BIGINT */ + case AntlrSQLLexer::SUB_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("SUB_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(SubTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: SUB_TBIGINT_BIGINT */ case AntlrSQLLexer::SUB_TINT_INT: { From 6e878c9bf04fbae98b66f692d7ac06399768d804 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 06:29:36 +0200 Subject: [PATCH 14/86] feat(meos): add TBIGINT_SHIFT_VALUE, TBIGINT_SCALE_VALUE, TBIGINT_SHIFT_SCALE_VALUE NES operators (W56) --- .../Meos/TbigintScaleValueLogicalFunction.hpp | 54 +++++++++ .../TbigintShiftScaleValueLogicalFunction.hpp | 55 +++++++++ .../Meos/TbigintShiftValueLogicalFunction.hpp | 54 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../Meos/TbigintScaleValueLogicalFunction.cpp | 105 +++++++++++++++++ .../TbigintShiftScaleValueLogicalFunction.cpp | 108 ++++++++++++++++++ .../Meos/TbigintShiftValueLogicalFunction.cpp | 105 +++++++++++++++++ .../TbigintScaleValuePhysicalFunction.hpp | 44 +++++++ ...TbigintShiftScaleValuePhysicalFunction.hpp | 45 ++++++++ .../TbigintShiftValuePhysicalFunction.hpp | 44 +++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../TbigintScaleValuePhysicalFunction.cpp | 91 +++++++++++++++ ...TbigintShiftScaleValuePhysicalFunction.cpp | 95 +++++++++++++++ .../TbigintShiftValuePhysicalFunction.cpp | 91 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 5 +- .../src/AntlrSQLQueryPlanCreator.cpp | 91 +++++++++++++++ 16 files changed, 992 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TbigintScaleValueLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TbigintShiftScaleValueLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TbigintShiftValueLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TbigintScaleValueLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TbigintShiftScaleValueLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TbigintShiftValueLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TbigintScaleValuePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TbigintShiftScaleValuePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TbigintShiftValuePhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TbigintScaleValuePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TbigintShiftScaleValuePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TbigintShiftValuePhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TbigintScaleValueLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TbigintScaleValueLogicalFunction.hpp new file mode 100644 index 0000000000..5bac4a42f7 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TbigintScaleValueLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tbigint_scale_value: scales a single-instant tbigint to a given int64_t width. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tbigint_scale_value`. Takes (value:FLOAT64, ts:UINT64, width:FLOAT64→int64_t), + * constructs a single-instant temporal, applies the scale, and returns FLOAT64. + */ +class TbigintScaleValueLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TbigintScaleValue"; + + TbigintScaleValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction width); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TbigintShiftScaleValueLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TbigintShiftScaleValueLogicalFunction.hpp new file mode 100644 index 0000000000..5dde046e33 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TbigintShiftScaleValueLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tbigint_shift_scale_value: shifts and scales a single-instant tbigint. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tbigint_shift_scale_value`. Takes (value:FLOAT64, ts:UINT64, shift:FLOAT64→int64_t, width:FLOAT64→int64_t), + * constructs a single-instant temporal, applies the shift-and-scale, and returns FLOAT64. + */ +class TbigintShiftScaleValueLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TbigintShiftScaleValue"; + + TbigintShiftScaleValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction shift, + LogicalFunction width); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TbigintShiftValueLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TbigintShiftValueLogicalFunction.hpp new file mode 100644 index 0000000000..0944b75091 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TbigintShiftValueLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tbigint_shift_value: shifts a single-instant tbigint by a constant int64_t. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tbigint_shift_value`. Takes (value:FLOAT64, ts:UINT64, shift:FLOAT64→int64_t), + * constructs a single-instant temporal, applies the shift, and returns FLOAT64. + */ +class TbigintShiftValueLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TbigintShiftValue"; + + TbigintShiftValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction shift); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 58a9c60a18..dfd88823a8 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -51,6 +51,9 @@ add_plugin(TfloatShiftScaleValue LogicalFunction nes-logical-operators TfloatShi add_plugin(TfloatShiftValue LogicalFunction nes-logical-operators TfloatShiftValueLogicalFunction.cpp) add_plugin(TfloatSin LogicalFunction nes-logical-operators TfloatSinLogicalFunction.cpp) add_plugin(TfloatTan LogicalFunction nes-logical-operators TfloatTanLogicalFunction.cpp) +add_plugin(TbigintScaleValue LogicalFunction nes-logical-operators TbigintScaleValueLogicalFunction.cpp) +add_plugin(TbigintShiftScaleValue LogicalFunction nes-logical-operators TbigintShiftScaleValueLogicalFunction.cpp) +add_plugin(TbigintShiftValue LogicalFunction nes-logical-operators TbigintShiftValueLogicalFunction.cpp) add_plugin(TbigintToTfloat LogicalFunction nes-logical-operators TbigintToTfloatLogicalFunction.cpp) add_plugin(TbigintToTint LogicalFunction nes-logical-operators TbigintToTintLogicalFunction.cpp) add_plugin(TfloatToTbigint LogicalFunction nes-logical-operators TfloatToTbigintLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TbigintScaleValueLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TbigintScaleValueLogicalFunction.cpp new file mode 100644 index 0000000000..e8e23a4277 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TbigintScaleValueLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TbigintScaleValueLogicalFunction::TbigintScaleValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction width) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(width)); +} + +DataType TbigintScaleValueLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TbigintScaleValueLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TbigintScaleValueLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TbigintScaleValueLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TbigintScaleValueLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TbigintScaleValueLogicalFunction::getType() const { return NAME; } + +bool TbigintScaleValueLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TbigintScaleValueLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TbigintScaleValueLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TbigintScaleValueLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTbigintScaleValueLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TbigintScaleValueLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TbigintScaleValueLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TbigintShiftScaleValueLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TbigintShiftScaleValueLogicalFunction.cpp new file mode 100644 index 0000000000..ea572eba5d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TbigintShiftScaleValueLogicalFunction.cpp @@ -0,0 +1,108 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TbigintShiftScaleValueLogicalFunction::TbigintShiftScaleValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction shift, + LogicalFunction width) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(shift)); + parameters.push_back(std::move(width)); +} + +DataType TbigintShiftScaleValueLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TbigintShiftScaleValueLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TbigintShiftScaleValueLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TbigintShiftScaleValueLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TbigintShiftScaleValueLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TbigintShiftScaleValueLogicalFunction::getType() const { return NAME; } + +bool TbigintShiftScaleValueLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TbigintShiftScaleValueLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TbigintShiftScaleValueLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TbigintShiftScaleValueLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTbigintShiftScaleValueLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TbigintShiftScaleValueLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TbigintShiftScaleValueLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TbigintShiftValueLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TbigintShiftValueLogicalFunction.cpp new file mode 100644 index 0000000000..090ac77e50 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TbigintShiftValueLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TbigintShiftValueLogicalFunction::TbigintShiftValueLogicalFunction(LogicalFunction value, + LogicalFunction ts, + LogicalFunction shift) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(shift)); +} + +DataType TbigintShiftValueLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TbigintShiftValueLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TbigintShiftValueLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TbigintShiftValueLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TbigintShiftValueLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TbigintShiftValueLogicalFunction::getType() const { return NAME; } + +bool TbigintShiftValueLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TbigintShiftValueLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TbigintShiftValueLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TbigintShiftValueLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTbigintShiftValueLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TbigintShiftValueLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TbigintShiftValueLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TbigintScaleValuePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TbigintScaleValuePhysicalFunction.hpp new file mode 100644 index 0000000000..5965e5c4dc --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TbigintScaleValuePhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tbigint_scale_value`. + * + * Per-event tbigint_scale_value: scales the value span of a single-instant tbigint + * to a given int64_t width. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TbigintScaleValuePhysicalFunction : public PhysicalFunctionConcept { +public: + TbigintScaleValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction widthFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TbigintShiftScaleValuePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TbigintShiftScaleValuePhysicalFunction.hpp new file mode 100644 index 0000000000..63758b98e2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TbigintShiftScaleValuePhysicalFunction.hpp @@ -0,0 +1,45 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tbigint_shift_scale_value`. + * + * Per-event tbigint_shift_scale_value: shifts the value span of a single-instant + * tbigint by a constant int64_t and scales it to the given int64_t width. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TbigintShiftScaleValuePhysicalFunction : public PhysicalFunctionConcept { +public: + TbigintShiftScaleValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction shiftFunction, + PhysicalFunction widthFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TbigintShiftValuePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TbigintShiftValuePhysicalFunction.hpp new file mode 100644 index 0000000000..7acf342692 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TbigintShiftValuePhysicalFunction.hpp @@ -0,0 +1,44 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tbigint_shift_value`. + * + * Per-event tbigint_shift_value: shifts the value span of a single-instant tbigint + * by a constant int64_t. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TbigintShiftValuePhysicalFunction : public PhysicalFunctionConcept { +public: + TbigintShiftValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction shiftFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 96feed49a1..0f6b6edc49 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -50,6 +50,9 @@ add_plugin(TfloatShiftScaleValue PhysicalFunction nes-physical-operators TfloatS add_plugin(TfloatShiftValue PhysicalFunction nes-physical-operators TfloatShiftValuePhysicalFunction.cpp) add_plugin(TfloatSin PhysicalFunction nes-physical-operators TfloatSinPhysicalFunction.cpp) add_plugin(TfloatTan PhysicalFunction nes-physical-operators TfloatTanPhysicalFunction.cpp) +add_plugin(TbigintScaleValue PhysicalFunction nes-physical-operators TbigintScaleValuePhysicalFunction.cpp) +add_plugin(TbigintShiftScaleValue PhysicalFunction nes-physical-operators TbigintShiftScaleValuePhysicalFunction.cpp) +add_plugin(TbigintShiftValue PhysicalFunction nes-physical-operators TbigintShiftValuePhysicalFunction.cpp) add_plugin(TbigintToTfloat PhysicalFunction nes-physical-operators TbigintToTfloatPhysicalFunction.cpp) add_plugin(TbigintToTint PhysicalFunction nes-physical-operators TbigintToTintPhysicalFunction.cpp) add_plugin(TfloatToTbigint PhysicalFunction nes-physical-operators TfloatToTbigintPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/TbigintScaleValuePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TbigintScaleValuePhysicalFunction.cpp new file mode 100644 index 0000000000..dc8c1fcfd9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TbigintScaleValuePhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TbigintScaleValuePhysicalFunction::TbigintScaleValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction widthFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(widthFunction)); +} + +VarVal TbigintScaleValuePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto width = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double width_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tbigint_scale_value(temp, static_cast(width_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tbigint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, width); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTbigintScaleValuePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TbigintScaleValuePhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TbigintScaleValuePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TbigintShiftScaleValuePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TbigintShiftScaleValuePhysicalFunction.cpp new file mode 100644 index 0000000000..b0e2632357 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TbigintShiftScaleValuePhysicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TbigintShiftScaleValuePhysicalFunction::TbigintShiftScaleValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction shiftFunction, + PhysicalFunction widthFunction) +{ + parameterFunctions.reserve(4); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(shiftFunction)); + parameterFunctions.push_back(std::move(widthFunction)); +} + +VarVal TbigintShiftScaleValuePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto shift = parameterValues[2].cast>(); + auto width = parameterValues[3].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double shift_d, double width_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tbigint_shift_scale_value(temp, static_cast(shift_d), static_cast(width_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tbigint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, shift, width); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTbigintShiftScaleValuePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TbigintShiftScaleValuePhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + auto arg3 = std::move(arguments.childFunctions[3]); + return TbigintShiftScaleValuePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TbigintShiftValuePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TbigintShiftValuePhysicalFunction.cpp new file mode 100644 index 0000000000..c2d8da4f88 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TbigintShiftValuePhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TbigintShiftValuePhysicalFunction::TbigintShiftValuePhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction shiftFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); + parameterFunctions.push_back(std::move(shiftFunction)); +} + +VarVal TbigintShiftValuePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + auto shift = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts, double shift_d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tbigint_shift_value(temp, static_cast(shift_d)); + free(temp); + if (!res) return 0.0; + double r = static_cast(tbigint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts, shift); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTbigintShiftValuePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TbigintShiftValuePhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TbigintShiftValuePhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 390a9bf826..ed8e0abcec 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -504,6 +504,9 @@ SUB_TBIGINT_BIGINT: 'SUB_TBIGINT_BIGINT' | 'sub_tbigint_bigint'; SUB_TFLOAT_FLOAT: 'SUB_TFLOAT_FLOAT' | 'sub_tfloat_float'; SUB_TINT_INT: 'SUB_TINT_INT' | 'sub_tint_int'; SUB_TNUMBER_TNUMBER: 'SUB_TNUMBER_TNUMBER' | 'sub_tnumber_tnumber'; +TBIGINT_SCALE_VALUE: 'TBIGINT_SCALE_VALUE' | 'tbigint_scale_value'; +TBIGINT_SHIFT_SCALE_VALUE: 'TBIGINT_SHIFT_SCALE_VALUE' | 'tbigint_shift_scale_value'; +TBIGINT_SHIFT_VALUE: 'TBIGINT_SHIFT_VALUE' | 'tbigint_shift_value'; TBIGINT_TO_TFLOAT: 'TBIGINT_TO_TFLOAT' | 'tbigint_to_tfloat'; TBIGINT_TO_TINT: 'TBIGINT_TO_TINT' | 'tbigint_to_tint'; TDISTANCE_TFLOAT_FLOAT: 'TDISTANCE_TFLOAT_FLOAT' | 'tdistance_tfloat_float'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 065bc99553..4fab4d252e 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -85,6 +85,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -2060,6 +2063,94 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: SUB_TNUMBER_TNUMBER */ + /* BEGIN CODEGEN PARSER GLUE: TBIGINT_SCALE_VALUE */ + case AntlrSQLLexer::TBIGINT_SCALE_VALUE: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TBIGINT_SCALE_VALUE requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TbigintScaleValueLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TBIGINT_SCALE_VALUE */ + /* BEGIN CODEGEN PARSER GLUE: TBIGINT_SHIFT_SCALE_VALUE */ + case AntlrSQLLexer::TBIGINT_SHIFT_SCALE_VALUE: + { + const auto argCount = context->expression().size(); + if (argCount != 4) + throw InvalidQuerySyntax("TBIGINT_SHIFT_SCALE_VALUE requires exactly 4 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a3 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TbigintShiftScaleValueLogicalFunction(a0, a1, a2, a3)); + } + break; + /* END CODEGEN PARSER GLUE: TBIGINT_SHIFT_SCALE_VALUE */ + /* BEGIN CODEGEN PARSER GLUE: TBIGINT_SHIFT_VALUE */ + case AntlrSQLLexer::TBIGINT_SHIFT_VALUE: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TBIGINT_SHIFT_VALUE requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TbigintShiftValueLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TBIGINT_SHIFT_VALUE */ /* BEGIN CODEGEN PARSER GLUE: TBIGINT_TO_TFLOAT */ case AntlrSQLLexer::TBIGINT_TO_TFLOAT: { From 09eb3474aee3b0cd4e1b7dd3c168ea8f22b16dee Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 06:39:52 +0200 Subject: [PATCH 15/86] feat(meos): add ADD/SUB/MUL/DIV_FLOAT_TFLOAT reversed NES operators (W57) Adds per-event scalar NES operators for reversed-order float arithmetic on tfloat temporals: ADD_FLOAT_TFLOAT, SUB_FLOAT_TFLOAT, MUL_FLOAT_TFLOAT, DIV_FLOAT_TFLOAT. Each operator takes (scalar:float, value:float, ts:uint64) and delegates to the corresponding MEOS add_float_tfloat / sub_float_tfloat / mul_float_tfloat / div_float_tfloat kernel. --- .../Meos/AddFloatTfloatLogicalFunction.hpp | 54 ++++++++ .../Meos/DivFloatTfloatLogicalFunction.hpp | 54 ++++++++ .../Meos/MulFloatTfloatLogicalFunction.hpp | 54 ++++++++ .../Meos/SubFloatTfloatLogicalFunction.hpp | 54 ++++++++ .../Meos/AddFloatTfloatLogicalFunction.cpp | 105 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/DivFloatTfloatLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/MulFloatTfloatLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/SubFloatTfloatLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/AddFloatTfloatPhysicalFunction.hpp | 43 +++++++ .../Meos/DivFloatTfloatPhysicalFunction.hpp | 43 +++++++ .../Meos/MulFloatTfloatPhysicalFunction.hpp | 43 +++++++ .../Meos/SubFloatTfloatPhysicalFunction.hpp | 43 +++++++ .../Meos/AddFloatTfloatPhysicalFunction.cpp | 91 +++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/DivFloatTfloatPhysicalFunction.cpp | 91 +++++++++++++ .../Meos/MulFloatTfloatPhysicalFunction.cpp | 91 +++++++++++++ .../Meos/SubFloatTfloatPhysicalFunction.cpp | 91 +++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 120 ++++++++++++++++++ 20 files changed, 1305 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AddFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/DivFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/MulFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/SubFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AddFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/DivFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/MulFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/SubFloatTfloatLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AddFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/DivFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/MulFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/SubFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AddFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/DivFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/MulFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/SubFloatTfloatPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AddFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AddFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..1454a1dc3a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AddFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event add_float_tfloat: adds a constant to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `add_float_tfloat`. Takes (scalar:FLOAT64, value:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the addition, and returns FLOAT64. + */ +class AddFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AddFloatTfloat"; + + AddFloatTfloatLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/DivFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/DivFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..78060cbec2 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/DivFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event div_float_tfloat: divides a constant by a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `div_float_tfloat`. Takes (scalar:FLOAT64, value:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the division, and returns FLOAT64. + */ +class DivFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "DivFloatTfloat"; + + DivFloatTfloatLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/MulFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/MulFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..c4f788803b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/MulFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event mul_float_tfloat: multiplies a constant by a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `mul_float_tfloat`. Takes (scalar:FLOAT64, value:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the multiplication, and returns FLOAT64. + */ +class MulFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "MulFloatTfloat"; + + MulFloatTfloatLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/SubFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/SubFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..a0ec1c5683 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/SubFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event sub_float_tfloat: subtracts a single-instant tfloat value from a constant. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `sub_float_tfloat`. Takes (scalar:FLOAT64, value:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the subtraction, and returns FLOAT64. + */ +class SubFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "SubFloatTfloat"; + + SubFloatTfloatLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AddFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AddFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..80d3f44e21 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AddFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AddFloatTfloatLogicalFunction::AddFloatTfloatLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(scalar)); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType AddFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AddFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AddFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AddFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AddFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AddFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool AddFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AddFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AddFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AddFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAddFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AddFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AddFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index dfd88823a8..1c4f89f633 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -24,6 +24,7 @@ add_plugin(TfloatDegrees LogicalFunction nes-logical-operators TfloatDegreesLogi add_plugin(TfloatFloor LogicalFunction nes-logical-operators TfloatFloorLogicalFunction.cpp) add_plugin(TfloatRadians LogicalFunction nes-logical-operators TfloatRadiansLogicalFunction.cpp) add_plugin(TfloatScaleValue LogicalFunction nes-logical-operators TfloatScaleValueLogicalFunction.cpp) +add_plugin(AddFloatTfloat LogicalFunction nes-logical-operators AddFloatTfloatLogicalFunction.cpp) add_plugin(AddTfloatFloat LogicalFunction nes-logical-operators AddTfloatFloatLogicalFunction.cpp) add_plugin(AddTbigintBigint LogicalFunction nes-logical-operators AddTbigintBigintLogicalFunction.cpp) add_plugin(AddTintInt LogicalFunction nes-logical-operators AddTintIntLogicalFunction.cpp) @@ -44,8 +45,11 @@ add_plugin(MulTnumberTnumber LogicalFunction nes-logical-operators MulTnumberTnu add_plugin(SubTbigintBigint LogicalFunction nes-logical-operators SubTbigintBigintLogicalFunction.cpp) add_plugin(SubTintInt LogicalFunction nes-logical-operators SubTintIntLogicalFunction.cpp) add_plugin(SubTnumberTnumber LogicalFunction nes-logical-operators SubTnumberTnumberLogicalFunction.cpp) +add_plugin(DivFloatTfloat LogicalFunction nes-logical-operators DivFloatTfloatLogicalFunction.cpp) add_plugin(DivTfloatFloat LogicalFunction nes-logical-operators DivTfloatFloatLogicalFunction.cpp) +add_plugin(MulFloatTfloat LogicalFunction nes-logical-operators MulFloatTfloatLogicalFunction.cpp) add_plugin(MulTfloatFloat LogicalFunction nes-logical-operators MulTfloatFloatLogicalFunction.cpp) +add_plugin(SubFloatTfloat LogicalFunction nes-logical-operators SubFloatTfloatLogicalFunction.cpp) add_plugin(SubTfloatFloat LogicalFunction nes-logical-operators SubTfloatFloatLogicalFunction.cpp) add_plugin(TfloatShiftScaleValue LogicalFunction nes-logical-operators TfloatShiftScaleValueLogicalFunction.cpp) add_plugin(TfloatShiftValue LogicalFunction nes-logical-operators TfloatShiftValueLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/DivFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/DivFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..321d299422 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/DivFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +DivFloatTfloatLogicalFunction::DivFloatTfloatLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(scalar)); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType DivFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction DivFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector DivFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction DivFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "DivFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view DivFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool DivFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string DivFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction DivFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction DivFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterDivFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "DivFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return DivFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/MulFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/MulFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..7a38b56a88 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/MulFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +MulFloatTfloatLogicalFunction::MulFloatTfloatLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(scalar)); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType MulFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction MulFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector MulFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction MulFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "MulFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view MulFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool MulFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string MulFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction MulFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction MulFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterMulFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "MulFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return MulFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/SubFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/SubFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..30d298ffb2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/SubFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +SubFloatTfloatLogicalFunction::SubFloatTfloatLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(scalar)); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType SubFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction SubFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector SubFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction SubFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "SubFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view SubFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool SubFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string SubFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction SubFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction SubFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterSubFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "SubFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return SubFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AddFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AddFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..8c37def1c6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AddFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `add_float_tfloat`. + * + * Per-event add_float_tfloat: adds a constant to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AddFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AddFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/DivFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/DivFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..3ac3044b9b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/DivFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `div_float_tfloat`. + * + * Per-event div_float_tfloat: divides a constant by a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class DivFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + DivFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/MulFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/MulFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..c9b029f509 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/MulFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `mul_float_tfloat`. + * + * Per-event mul_float_tfloat: multiplies a constant by a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class MulFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + MulFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/SubFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/SubFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..bc997c36cc --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/SubFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `sub_float_tfloat`. + * + * Per-event sub_float_tfloat: subtracts a single-instant tfloat value from a constant. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class SubFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + SubFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AddFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AddFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..50cf48bbf9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AddFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AddFloatTfloatPhysicalFunction::AddFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AddFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double scalar, double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = add_float_tfloat(scalar, temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAddFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AddFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AddFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 0f6b6edc49..68e4937d0f 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -23,6 +23,7 @@ add_plugin(TfloatDegrees PhysicalFunction nes-physical-operators TfloatDegreesPh add_plugin(TfloatFloor PhysicalFunction nes-physical-operators TfloatFloorPhysicalFunction.cpp) add_plugin(TfloatRadians PhysicalFunction nes-physical-operators TfloatRadiansPhysicalFunction.cpp) add_plugin(TfloatScaleValue PhysicalFunction nes-physical-operators TfloatScaleValuePhysicalFunction.cpp) +add_plugin(AddFloatTfloat PhysicalFunction nes-physical-operators AddFloatTfloatPhysicalFunction.cpp) add_plugin(AddTfloatFloat PhysicalFunction nes-physical-operators AddTfloatFloatPhysicalFunction.cpp) add_plugin(AddTbigintBigint PhysicalFunction nes-physical-operators AddTbigintBigintPhysicalFunction.cpp) add_plugin(AddTintInt PhysicalFunction nes-physical-operators AddTintIntPhysicalFunction.cpp) @@ -43,8 +44,11 @@ add_plugin(MulTnumberTnumber PhysicalFunction nes-physical-operators MulTnumberT add_plugin(SubTbigintBigint PhysicalFunction nes-physical-operators SubTbigintBigintPhysicalFunction.cpp) add_plugin(SubTintInt PhysicalFunction nes-physical-operators SubTintIntPhysicalFunction.cpp) add_plugin(SubTnumberTnumber PhysicalFunction nes-physical-operators SubTnumberTnumberPhysicalFunction.cpp) +add_plugin(DivFloatTfloat PhysicalFunction nes-physical-operators DivFloatTfloatPhysicalFunction.cpp) add_plugin(DivTfloatFloat PhysicalFunction nes-physical-operators DivTfloatFloatPhysicalFunction.cpp) +add_plugin(MulFloatTfloat PhysicalFunction nes-physical-operators MulFloatTfloatPhysicalFunction.cpp) add_plugin(MulTfloatFloat PhysicalFunction nes-physical-operators MulTfloatFloatPhysicalFunction.cpp) +add_plugin(SubFloatTfloat PhysicalFunction nes-physical-operators SubFloatTfloatPhysicalFunction.cpp) add_plugin(SubTfloatFloat PhysicalFunction nes-physical-operators SubTfloatFloatPhysicalFunction.cpp) add_plugin(TfloatShiftScaleValue PhysicalFunction nes-physical-operators TfloatShiftScaleValuePhysicalFunction.cpp) add_plugin(TfloatShiftValue PhysicalFunction nes-physical-operators TfloatShiftValuePhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/DivFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/DivFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..f920a90108 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/DivFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +DivFloatTfloatPhysicalFunction::DivFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal DivFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double scalar, double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = div_float_tfloat(scalar, temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterDivFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "DivFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return DivFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/MulFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/MulFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..94fe98aa57 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/MulFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +MulFloatTfloatPhysicalFunction::MulFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal MulFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double scalar, double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = mul_float_tfloat(scalar, temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterMulFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "MulFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return MulFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/SubFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/SubFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..1f4e5254ac --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/SubFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +SubFloatTfloatPhysicalFunction::SubFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal SubFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double scalar, double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = sub_float_tfloat(scalar, temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterSubFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "SubFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return SubFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index ed8e0abcec..674ef5c733 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_FLOAT_TFLOAT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_FLOAT_TFLOAT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_FLOAT_TFLOAT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_FLOAT_TFLOAT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -488,18 +488,22 @@ TEMPORAL_AINTERSECTS_GEOMETRY: 'TEMPORAL_AINTERSECTS_GEOMETRY' | 'temporal_ainte TEMPORAL_ECONTAINS_GEOMETRY: 'TEMPORAL_ECONTAINS_GEOMETRY' | 'temporal_econtains_geometry'; EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; TGEO_AT_STBOX: 'TGEO_AT_STBOX' | 'tgeo_at_stbox'; +ADD_FLOAT_TFLOAT: 'ADD_FLOAT_TFLOAT' | 'add_float_tfloat'; ADD_TBIGINT_BIGINT: 'ADD_TBIGINT_BIGINT' | 'add_tbigint_bigint'; ADD_TFLOAT_FLOAT: 'ADD_TFLOAT_FLOAT' | 'add_tfloat_float'; ADD_TINT_INT: 'ADD_TINT_INT' | 'add_tint_int'; ADD_TNUMBER_TNUMBER: 'ADD_TNUMBER_TNUMBER' | 'add_tnumber_tnumber'; +DIV_FLOAT_TFLOAT: 'DIV_FLOAT_TFLOAT' | 'div_float_tfloat'; DIV_TBIGINT_BIGINT: 'DIV_TBIGINT_BIGINT' | 'div_tbigint_bigint'; DIV_TFLOAT_FLOAT: 'DIV_TFLOAT_FLOAT' | 'div_tfloat_float'; DIV_TINT_INT: 'DIV_TINT_INT' | 'div_tint_int'; DIV_TNUMBER_TNUMBER: 'DIV_TNUMBER_TNUMBER' | 'div_tnumber_tnumber'; +MUL_FLOAT_TFLOAT: 'MUL_FLOAT_TFLOAT' | 'mul_float_tfloat'; MUL_TBIGINT_BIGINT: 'MUL_TBIGINT_BIGINT' | 'mul_tbigint_bigint'; MUL_TFLOAT_FLOAT: 'MUL_TFLOAT_FLOAT' | 'mul_tfloat_float'; MUL_TINT_INT: 'MUL_TINT_INT' | 'mul_tint_int'; MUL_TNUMBER_TNUMBER: 'MUL_TNUMBER_TNUMBER' | 'mul_tnumber_tnumber'; +SUB_FLOAT_TFLOAT: 'SUB_FLOAT_TFLOAT' | 'sub_float_tfloat'; SUB_TBIGINT_BIGINT: 'SUB_TBIGINT_BIGINT' | 'sub_tbigint_bigint'; SUB_TFLOAT_FLOAT: 'SUB_TFLOAT_FLOAT' | 'sub_tfloat_float'; SUB_TINT_INT: 'SUB_TINT_INT' | 'sub_tint_int'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 4fab4d252e..06f381369f 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -69,18 +69,22 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -1598,6 +1602,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TNUMBER_ABS */ + /* BEGIN CODEGEN PARSER GLUE: ADD_FLOAT_TFLOAT */ + case AntlrSQLLexer::ADD_FLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ADD_FLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AddFloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ADD_FLOAT_TFLOAT */ /* BEGIN CODEGEN PARSER GLUE: ADD_TFLOAT_FLOAT */ case AntlrSQLLexer::ADD_TFLOAT_FLOAT: { @@ -1627,6 +1660,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: ADD_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: DIV_FLOAT_TFLOAT */ + case AntlrSQLLexer::DIV_FLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("DIV_FLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(DivFloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: DIV_FLOAT_TFLOAT */ /* BEGIN CODEGEN PARSER GLUE: DIV_TFLOAT_FLOAT */ case AntlrSQLLexer::DIV_TFLOAT_FLOAT: { @@ -1656,6 +1718,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: DIV_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: MUL_FLOAT_TFLOAT */ + case AntlrSQLLexer::MUL_FLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("MUL_FLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(MulFloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: MUL_FLOAT_TFLOAT */ /* BEGIN CODEGEN PARSER GLUE: MUL_TFLOAT_FLOAT */ case AntlrSQLLexer::MUL_TFLOAT_FLOAT: { @@ -1685,6 +1776,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: MUL_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: SUB_FLOAT_TFLOAT */ + case AntlrSQLLexer::SUB_FLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("SUB_FLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(SubFloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: SUB_FLOAT_TFLOAT */ /* BEGIN CODEGEN PARSER GLUE: SUB_TFLOAT_FLOAT */ case AntlrSQLLexer::SUB_TFLOAT_FLOAT: { From e7a09dc598f6576734f94dc4babdb32c694e6c25 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 06:46:22 +0200 Subject: [PATCH 16/86] feat(meos): add ADD/SUB/MUL/DIV_INT_TINT reversed NES operators (W58) Adds per-event scalar NES operators for reversed-order integer arithmetic on tint temporals: ADD_INT_TINT, SUB_INT_TINT, MUL_INT_TINT, DIV_INT_TINT. Each operator takes (scalar:int, value:int, ts:uint64) and delegates to the corresponding MEOS add_int_tint / sub_int_tint / mul_int_tint / div_int_tint kernel. --- .../Meos/AddIntTintLogicalFunction.hpp | 54 ++++++++ .../Meos/DivIntTintLogicalFunction.hpp | 54 ++++++++ .../Meos/MulIntTintLogicalFunction.hpp | 54 ++++++++ .../Meos/SubIntTintLogicalFunction.hpp | 54 ++++++++ .../Meos/AddIntTintLogicalFunction.cpp | 105 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/DivIntTintLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/MulIntTintLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/SubIntTintLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/AddIntTintPhysicalFunction.hpp | 43 +++++++ .../Meos/DivIntTintPhysicalFunction.hpp | 43 +++++++ .../Meos/MulIntTintPhysicalFunction.hpp | 43 +++++++ .../Meos/SubIntTintPhysicalFunction.hpp | 43 +++++++ .../Meos/AddIntTintPhysicalFunction.cpp | 91 +++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/DivIntTintPhysicalFunction.cpp | 91 +++++++++++++ .../Meos/MulIntTintPhysicalFunction.cpp | 91 +++++++++++++ .../Meos/SubIntTintPhysicalFunction.cpp | 91 +++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 120 ++++++++++++++++++ 20 files changed, 1305 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AddIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/DivIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/MulIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/SubIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AddIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/DivIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/MulIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/SubIntTintLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AddIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/DivIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/MulIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/SubIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AddIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/DivIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/MulIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/SubIntTintPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AddIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AddIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..db3ef60e22 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AddIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event add_int_tint: adds a constant to a single-instant tint value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `add_int_tint`. Takes (scalar:FLOAT64, value:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the addition, and returns FLOAT64. + */ +class AddIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AddIntTint"; + + AddIntTintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/DivIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/DivIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..f48f877b8b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/DivIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event div_int_tint: divides a constant by a single-instant tint value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `div_int_tint`. Takes (scalar:FLOAT64, value:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the division, and returns FLOAT64. + */ +class DivIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "DivIntTint"; + + DivIntTintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/MulIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/MulIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..a2f0f7f2b3 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/MulIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event mul_int_tint: multiplies a constant by a single-instant tint value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `mul_int_tint`. Takes (scalar:FLOAT64, value:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the multiplication, and returns FLOAT64. + */ +class MulIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "MulIntTint"; + + MulIntTintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/SubIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/SubIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..5e3f4a8c94 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/SubIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event sub_int_tint: subtracts a single-instant tint value from a constant. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `sub_int_tint`. Takes (scalar:FLOAT64, value:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the subtraction, and returns FLOAT64. + */ +class SubIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "SubIntTint"; + + SubIntTintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AddIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AddIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..184848e839 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AddIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AddIntTintLogicalFunction::AddIntTintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(scalar)); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType AddIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AddIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AddIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AddIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AddIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AddIntTintLogicalFunction::getType() const { return NAME; } + +bool AddIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AddIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AddIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AddIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAddIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AddIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AddIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 1c4f89f633..b183f783d5 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -27,6 +27,7 @@ add_plugin(TfloatScaleValue LogicalFunction nes-logical-operators TfloatScaleVal add_plugin(AddFloatTfloat LogicalFunction nes-logical-operators AddFloatTfloatLogicalFunction.cpp) add_plugin(AddTfloatFloat LogicalFunction nes-logical-operators AddTfloatFloatLogicalFunction.cpp) add_plugin(AddTbigintBigint LogicalFunction nes-logical-operators AddTbigintBigintLogicalFunction.cpp) +add_plugin(AddIntTint LogicalFunction nes-logical-operators AddIntTintLogicalFunction.cpp) add_plugin(AddTintInt LogicalFunction nes-logical-operators AddTintIntLogicalFunction.cpp) add_plugin(AddTnumberTnumber LogicalFunction nes-logical-operators AddTnumberTnumberLogicalFunction.cpp) add_plugin(TdistanceTfloatFloat LogicalFunction nes-logical-operators TdistanceTfloatFloatLogicalFunction.cpp) @@ -37,12 +38,15 @@ add_plugin(TintScaleValue LogicalFunction nes-logical-operators TintScaleValueLo add_plugin(TintShiftScaleValue LogicalFunction nes-logical-operators TintShiftScaleValueLogicalFunction.cpp) add_plugin(TintShiftValue LogicalFunction nes-logical-operators TintShiftValueLogicalFunction.cpp) add_plugin(DivTbigintBigint LogicalFunction nes-logical-operators DivTbigintBigintLogicalFunction.cpp) +add_plugin(DivIntTint LogicalFunction nes-logical-operators DivIntTintLogicalFunction.cpp) add_plugin(DivTintInt LogicalFunction nes-logical-operators DivTintIntLogicalFunction.cpp) add_plugin(DivTnumberTnumber LogicalFunction nes-logical-operators DivTnumberTnumberLogicalFunction.cpp) add_plugin(MulTbigintBigint LogicalFunction nes-logical-operators MulTbigintBigintLogicalFunction.cpp) +add_plugin(MulIntTint LogicalFunction nes-logical-operators MulIntTintLogicalFunction.cpp) add_plugin(MulTintInt LogicalFunction nes-logical-operators MulTintIntLogicalFunction.cpp) add_plugin(MulTnumberTnumber LogicalFunction nes-logical-operators MulTnumberTnumberLogicalFunction.cpp) add_plugin(SubTbigintBigint LogicalFunction nes-logical-operators SubTbigintBigintLogicalFunction.cpp) +add_plugin(SubIntTint LogicalFunction nes-logical-operators SubIntTintLogicalFunction.cpp) add_plugin(SubTintInt LogicalFunction nes-logical-operators SubTintIntLogicalFunction.cpp) add_plugin(SubTnumberTnumber LogicalFunction nes-logical-operators SubTnumberTnumberLogicalFunction.cpp) add_plugin(DivFloatTfloat LogicalFunction nes-logical-operators DivFloatTfloatLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/DivIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/DivIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..5abd6ce582 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/DivIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +DivIntTintLogicalFunction::DivIntTintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(scalar)); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType DivIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction DivIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector DivIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction DivIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "DivIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view DivIntTintLogicalFunction::getType() const { return NAME; } + +bool DivIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string DivIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction DivIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction DivIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterDivIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "DivIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return DivIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/MulIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/MulIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..6b5cc688ee --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/MulIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +MulIntTintLogicalFunction::MulIntTintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(scalar)); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType MulIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction MulIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector MulIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction MulIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "MulIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view MulIntTintLogicalFunction::getType() const { return NAME; } + +bool MulIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string MulIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction MulIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction MulIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterMulIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "MulIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return MulIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/SubIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/SubIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..137088701d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/SubIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +SubIntTintLogicalFunction::SubIntTintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(scalar)); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType SubIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction SubIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector SubIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction SubIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "SubIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view SubIntTintLogicalFunction::getType() const { return NAME; } + +bool SubIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string SubIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction SubIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction SubIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterSubIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "SubIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return SubIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AddIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AddIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..086b9058c2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AddIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `add_int_tint`. + * + * Per-event add_int_tint: adds a constant to a single-instant tint value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AddIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + AddIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/DivIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/DivIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..e368a96708 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/DivIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `div_int_tint`. + * + * Per-event div_int_tint: divides a constant by a single-instant tint value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class DivIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + DivIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/MulIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/MulIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..c5799619f8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/MulIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `mul_int_tint`. + * + * Per-event mul_int_tint: multiplies a constant by a single-instant tint value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class MulIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + MulIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/SubIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/SubIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..051774283e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/SubIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `sub_int_tint`. + * + * Per-event sub_int_tint: subtracts a single-instant tint value from a constant. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class SubIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + SubIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AddIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AddIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..f6cb83b692 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AddIntTintPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AddIntTintPhysicalFunction::AddIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AddIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double scalar_d, double value_d, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value_d), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = add_int_tint(static_cast(scalar_d), temp); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAddIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AddIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AddIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 68e4937d0f..d6ede70801 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -26,6 +26,7 @@ add_plugin(TfloatScaleValue PhysicalFunction nes-physical-operators TfloatScaleV add_plugin(AddFloatTfloat PhysicalFunction nes-physical-operators AddFloatTfloatPhysicalFunction.cpp) add_plugin(AddTfloatFloat PhysicalFunction nes-physical-operators AddTfloatFloatPhysicalFunction.cpp) add_plugin(AddTbigintBigint PhysicalFunction nes-physical-operators AddTbigintBigintPhysicalFunction.cpp) +add_plugin(AddIntTint PhysicalFunction nes-physical-operators AddIntTintPhysicalFunction.cpp) add_plugin(AddTintInt PhysicalFunction nes-physical-operators AddTintIntPhysicalFunction.cpp) add_plugin(AddTnumberTnumber PhysicalFunction nes-physical-operators AddTnumberTnumberPhysicalFunction.cpp) add_plugin(TdistanceTfloatFloat PhysicalFunction nes-physical-operators TdistanceTfloatFloatPhysicalFunction.cpp) @@ -36,12 +37,15 @@ add_plugin(TintScaleValue PhysicalFunction nes-physical-operators TintScaleValue add_plugin(TintShiftScaleValue PhysicalFunction nes-physical-operators TintShiftScaleValuePhysicalFunction.cpp) add_plugin(TintShiftValue PhysicalFunction nes-physical-operators TintShiftValuePhysicalFunction.cpp) add_plugin(DivTbigintBigint PhysicalFunction nes-physical-operators DivTbigintBigintPhysicalFunction.cpp) +add_plugin(DivIntTint PhysicalFunction nes-physical-operators DivIntTintPhysicalFunction.cpp) add_plugin(DivTintInt PhysicalFunction nes-physical-operators DivTintIntPhysicalFunction.cpp) add_plugin(DivTnumberTnumber PhysicalFunction nes-physical-operators DivTnumberTnumberPhysicalFunction.cpp) add_plugin(MulTbigintBigint PhysicalFunction nes-physical-operators MulTbigintBigintPhysicalFunction.cpp) +add_plugin(MulIntTint PhysicalFunction nes-physical-operators MulIntTintPhysicalFunction.cpp) add_plugin(MulTintInt PhysicalFunction nes-physical-operators MulTintIntPhysicalFunction.cpp) add_plugin(MulTnumberTnumber PhysicalFunction nes-physical-operators MulTnumberTnumberPhysicalFunction.cpp) add_plugin(SubTbigintBigint PhysicalFunction nes-physical-operators SubTbigintBigintPhysicalFunction.cpp) +add_plugin(SubIntTint PhysicalFunction nes-physical-operators SubIntTintPhysicalFunction.cpp) add_plugin(SubTintInt PhysicalFunction nes-physical-operators SubTintIntPhysicalFunction.cpp) add_plugin(SubTnumberTnumber PhysicalFunction nes-physical-operators SubTnumberTnumberPhysicalFunction.cpp) add_plugin(DivFloatTfloat PhysicalFunction nes-physical-operators DivFloatTfloatPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/DivIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/DivIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..d612334db7 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/DivIntTintPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +DivIntTintPhysicalFunction::DivIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal DivIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double scalar_d, double value_d, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value_d), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = div_int_tint(static_cast(scalar_d), temp); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterDivIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "DivIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return DivIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/MulIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/MulIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..19b58599e9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/MulIntTintPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +MulIntTintPhysicalFunction::MulIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal MulIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double scalar_d, double value_d, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value_d), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = mul_int_tint(static_cast(scalar_d), temp); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterMulIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "MulIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return MulIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/SubIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/SubIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..07f4ec11c7 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/SubIntTintPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +SubIntTintPhysicalFunction::SubIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal SubIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double scalar_d, double value_d, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value_d), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = sub_int_tint(static_cast(scalar_d), temp); + free(temp); + if (!res) return 0.0; + double r = static_cast(tint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterSubIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "SubIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return SubIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 674ef5c733..e38329c1d3 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_FLOAT_TFLOAT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_FLOAT_TFLOAT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_FLOAT_TFLOAT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_FLOAT_TFLOAT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -491,21 +491,25 @@ TGEO_AT_STBOX: 'TGEO_AT_STBOX' | 'tgeo_at_stbox'; ADD_FLOAT_TFLOAT: 'ADD_FLOAT_TFLOAT' | 'add_float_tfloat'; ADD_TBIGINT_BIGINT: 'ADD_TBIGINT_BIGINT' | 'add_tbigint_bigint'; ADD_TFLOAT_FLOAT: 'ADD_TFLOAT_FLOAT' | 'add_tfloat_float'; +ADD_INT_TINT: 'ADD_INT_TINT' | 'add_int_tint'; ADD_TINT_INT: 'ADD_TINT_INT' | 'add_tint_int'; ADD_TNUMBER_TNUMBER: 'ADD_TNUMBER_TNUMBER' | 'add_tnumber_tnumber'; DIV_FLOAT_TFLOAT: 'DIV_FLOAT_TFLOAT' | 'div_float_tfloat'; DIV_TBIGINT_BIGINT: 'DIV_TBIGINT_BIGINT' | 'div_tbigint_bigint'; DIV_TFLOAT_FLOAT: 'DIV_TFLOAT_FLOAT' | 'div_tfloat_float'; +DIV_INT_TINT: 'DIV_INT_TINT' | 'div_int_tint'; DIV_TINT_INT: 'DIV_TINT_INT' | 'div_tint_int'; DIV_TNUMBER_TNUMBER: 'DIV_TNUMBER_TNUMBER' | 'div_tnumber_tnumber'; MUL_FLOAT_TFLOAT: 'MUL_FLOAT_TFLOAT' | 'mul_float_tfloat'; MUL_TBIGINT_BIGINT: 'MUL_TBIGINT_BIGINT' | 'mul_tbigint_bigint'; MUL_TFLOAT_FLOAT: 'MUL_TFLOAT_FLOAT' | 'mul_tfloat_float'; +MUL_INT_TINT: 'MUL_INT_TINT' | 'mul_int_tint'; MUL_TINT_INT: 'MUL_TINT_INT' | 'mul_tint_int'; MUL_TNUMBER_TNUMBER: 'MUL_TNUMBER_TNUMBER' | 'mul_tnumber_tnumber'; SUB_FLOAT_TFLOAT: 'SUB_FLOAT_TFLOAT' | 'sub_float_tfloat'; SUB_TBIGINT_BIGINT: 'SUB_TBIGINT_BIGINT' | 'sub_tbigint_bigint'; SUB_TFLOAT_FLOAT: 'SUB_TFLOAT_FLOAT' | 'sub_tfloat_float'; +SUB_INT_TINT: 'SUB_INT_TINT' | 'sub_int_tint'; SUB_TINT_INT: 'SUB_TINT_INT' | 'sub_tint_int'; SUB_TNUMBER_TNUMBER: 'SUB_TNUMBER_TNUMBER' | 'sub_tnumber_tnumber'; TBIGINT_SCALE_VALUE: 'TBIGINT_SCALE_VALUE' | 'tbigint_scale_value'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 06f381369f..c7666a5cdc 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -72,21 +72,25 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -1863,6 +1867,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: ADD_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ADD_INT_TINT */ + case AntlrSQLLexer::ADD_INT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ADD_INT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AddIntTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ADD_INT_TINT */ case AntlrSQLLexer::ADD_TINT_INT: { @@ -1921,6 +1954,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: DIV_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: DIV_INT_TINT */ + case AntlrSQLLexer::DIV_INT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("DIV_INT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(DivIntTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: DIV_INT_TINT */ case AntlrSQLLexer::DIV_TINT_INT: { @@ -1979,6 +2041,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: MUL_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: MUL_INT_TINT */ + case AntlrSQLLexer::MUL_INT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("MUL_INT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(MulIntTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: MUL_INT_TINT */ case AntlrSQLLexer::MUL_TINT_INT: { @@ -2037,6 +2128,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: SUB_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: SUB_INT_TINT */ + case AntlrSQLLexer::SUB_INT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("SUB_INT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(SubIntTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: SUB_INT_TINT */ case AntlrSQLLexer::SUB_TINT_INT: { From 8a4f6c9a9465c53cb9e23a277dc1a930b6d58b2b Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 06:53:10 +0200 Subject: [PATCH 17/86] feat(meos): add ADD/SUB/MUL/DIV_BIGINT_TBIGINT reversed NES operators (W59) Adds per-event scalar NES operators for reversed-order bigint arithmetic on tbigint temporals: ADD_BIGINT_TBIGINT, SUB_BIGINT_TBIGINT, MUL_BIGINT_TBIGINT, DIV_BIGINT_TBIGINT. Each operator takes (scalar:bigint, value:bigint, ts:uint64) and delegates to the corresponding MEOS add_bigint_tbigint / sub_bigint_tbigint / mul_bigint_tbigint / div_bigint_tbigint kernel. --- .../Meos/AddBigintTbigintLogicalFunction.hpp | 54 ++++++++ .../Meos/DivBigintTbigintLogicalFunction.hpp | 54 ++++++++ .../Meos/MulBigintTbigintLogicalFunction.hpp | 54 ++++++++ .../Meos/SubBigintTbigintLogicalFunction.hpp | 54 ++++++++ .../Meos/AddBigintTbigintLogicalFunction.cpp | 105 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/DivBigintTbigintLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/MulBigintTbigintLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/SubBigintTbigintLogicalFunction.cpp | 105 +++++++++++++++ .../Meos/AddBigintTbigintPhysicalFunction.hpp | 43 +++++++ .../Meos/DivBigintTbigintPhysicalFunction.hpp | 43 +++++++ .../Meos/MulBigintTbigintPhysicalFunction.hpp | 43 +++++++ .../Meos/SubBigintTbigintPhysicalFunction.hpp | 43 +++++++ .../Meos/AddBigintTbigintPhysicalFunction.cpp | 92 ++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/DivBigintTbigintPhysicalFunction.cpp | 92 ++++++++++++++ .../Meos/MulBigintTbigintPhysicalFunction.cpp | 92 ++++++++++++++ .../Meos/SubBigintTbigintPhysicalFunction.cpp | 92 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 120 ++++++++++++++++++ 20 files changed, 1309 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AddBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/DivBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/MulBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/SubBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AddBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/DivBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/MulBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/SubBigintTbigintLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AddBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/DivBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/MulBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/SubBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AddBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/DivBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/MulBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/SubBigintTbigintPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AddBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AddBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..99a8dcb629 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AddBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event add_bigint_tbigint: adds a constant int64 scalar to a single-instant tbigint value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `add_bigint_tbigint`. Takes (scalar:FLOAT64→int64, value:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the addition, and returns FLOAT64. + */ +class AddBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AddBigintTbigint"; + + AddBigintTbigintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/DivBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/DivBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..993b9666e1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/DivBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event div_bigint_tbigint: divides a constant int64 scalar by a single-instant tbigint value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `div_bigint_tbigint`. Takes (scalar:FLOAT64→int64, value:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the division, and returns FLOAT64. + */ +class DivBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "DivBigintTbigint"; + + DivBigintTbigintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/MulBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/MulBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..bc3e2244f5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/MulBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event mul_bigint_tbigint: multiplies a constant int64 scalar by a single-instant tbigint value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `mul_bigint_tbigint`. Takes (scalar:FLOAT64→int64, value:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the multiplication, and returns FLOAT64. + */ +class MulBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "MulBigintTbigint"; + + MulBigintTbigintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/SubBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/SubBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..dfd0d17747 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/SubBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event sub_bigint_tbigint: subtracts a single-instant tbigint value from a constant int64 scalar. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `sub_bigint_tbigint`. Takes (scalar:FLOAT64→int64, value:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the subtraction, and returns FLOAT64. + */ +class SubBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "SubBigintTbigint"; + + SubBigintTbigintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AddBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AddBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..4c0eae2820 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AddBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AddBigintTbigintLogicalFunction::AddBigintTbigintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(scalar)); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType AddBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AddBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AddBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AddBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AddBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AddBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool AddBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AddBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AddBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AddBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAddBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AddBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AddBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index b183f783d5..a99de0cdb4 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -26,6 +26,7 @@ add_plugin(TfloatRadians LogicalFunction nes-logical-operators TfloatRadiansLogi add_plugin(TfloatScaleValue LogicalFunction nes-logical-operators TfloatScaleValueLogicalFunction.cpp) add_plugin(AddFloatTfloat LogicalFunction nes-logical-operators AddFloatTfloatLogicalFunction.cpp) add_plugin(AddTfloatFloat LogicalFunction nes-logical-operators AddTfloatFloatLogicalFunction.cpp) +add_plugin(AddBigintTbigint LogicalFunction nes-logical-operators AddBigintTbigintLogicalFunction.cpp) add_plugin(AddTbigintBigint LogicalFunction nes-logical-operators AddTbigintBigintLogicalFunction.cpp) add_plugin(AddIntTint LogicalFunction nes-logical-operators AddIntTintLogicalFunction.cpp) add_plugin(AddTintInt LogicalFunction nes-logical-operators AddTintIntLogicalFunction.cpp) @@ -37,14 +38,17 @@ add_plugin(TemporalRound LogicalFunction nes-logical-operators TemporalRoundLogi add_plugin(TintScaleValue LogicalFunction nes-logical-operators TintScaleValueLogicalFunction.cpp) add_plugin(TintShiftScaleValue LogicalFunction nes-logical-operators TintShiftScaleValueLogicalFunction.cpp) add_plugin(TintShiftValue LogicalFunction nes-logical-operators TintShiftValueLogicalFunction.cpp) +add_plugin(DivBigintTbigint LogicalFunction nes-logical-operators DivBigintTbigintLogicalFunction.cpp) add_plugin(DivTbigintBigint LogicalFunction nes-logical-operators DivTbigintBigintLogicalFunction.cpp) add_plugin(DivIntTint LogicalFunction nes-logical-operators DivIntTintLogicalFunction.cpp) add_plugin(DivTintInt LogicalFunction nes-logical-operators DivTintIntLogicalFunction.cpp) add_plugin(DivTnumberTnumber LogicalFunction nes-logical-operators DivTnumberTnumberLogicalFunction.cpp) +add_plugin(MulBigintTbigint LogicalFunction nes-logical-operators MulBigintTbigintLogicalFunction.cpp) add_plugin(MulTbigintBigint LogicalFunction nes-logical-operators MulTbigintBigintLogicalFunction.cpp) add_plugin(MulIntTint LogicalFunction nes-logical-operators MulIntTintLogicalFunction.cpp) add_plugin(MulTintInt LogicalFunction nes-logical-operators MulTintIntLogicalFunction.cpp) add_plugin(MulTnumberTnumber LogicalFunction nes-logical-operators MulTnumberTnumberLogicalFunction.cpp) +add_plugin(SubBigintTbigint LogicalFunction nes-logical-operators SubBigintTbigintLogicalFunction.cpp) add_plugin(SubTbigintBigint LogicalFunction nes-logical-operators SubTbigintBigintLogicalFunction.cpp) add_plugin(SubIntTint LogicalFunction nes-logical-operators SubIntTintLogicalFunction.cpp) add_plugin(SubTintInt LogicalFunction nes-logical-operators SubTintIntLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/DivBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/DivBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..166a3c2100 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/DivBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +DivBigintTbigintLogicalFunction::DivBigintTbigintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(scalar)); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType DivBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction DivBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector DivBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction DivBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "DivBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view DivBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool DivBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string DivBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction DivBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction DivBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterDivBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "DivBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return DivBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/MulBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/MulBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..97c43c36c7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/MulBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +MulBigintTbigintLogicalFunction::MulBigintTbigintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(scalar)); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType MulBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction MulBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector MulBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction MulBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "MulBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view MulBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool MulBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string MulBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction MulBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction MulBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterMulBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "MulBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return MulBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/SubBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/SubBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..1d28d41eeb --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/SubBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +SubBigintTbigintLogicalFunction::SubBigintTbigintLogicalFunction(LogicalFunction scalar, + LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(scalar)); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType SubBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction SubBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector SubBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction SubBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "SubBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view SubBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool SubBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string SubBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction SubBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction SubBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterSubBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "SubBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return SubBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AddBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AddBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..002afad790 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AddBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `add_bigint_tbigint`. + * + * Per-event add_bigint_tbigint: adds a constant int64 scalar to a single-instant tbigint value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AddBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AddBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/DivBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/DivBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..388ea20550 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/DivBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `div_bigint_tbigint`. + * + * Per-event div_bigint_tbigint: divides a constant int64 scalar by a single-instant tbigint value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class DivBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + DivBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/MulBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/MulBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..8e83307019 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/MulBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `mul_bigint_tbigint`. + * + * Per-event mul_bigint_tbigint: multiplies a constant int64 scalar by a single-instant tbigint value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class MulBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + MulBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/SubBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/SubBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..3c3558ab49 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/SubBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `sub_bigint_tbigint`. + * + * Per-event sub_bigint_tbigint: subtracts a single-instant tbigint value from a constant int64 scalar. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class SubBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + SubBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AddBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AddBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..524b303ad8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AddBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AddBigintTbigintPhysicalFunction::AddBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AddBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double scalar_d, double value_d, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value_d), + MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = add_bigint_tbigint(static_cast(scalar_d), temp); + free(temp); + if (!res) return 0.0; + double r = static_cast(tbigint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAddBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AddBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AddBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index d6ede70801..036d4bdf7d 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -25,6 +25,7 @@ add_plugin(TfloatRadians PhysicalFunction nes-physical-operators TfloatRadiansPh add_plugin(TfloatScaleValue PhysicalFunction nes-physical-operators TfloatScaleValuePhysicalFunction.cpp) add_plugin(AddFloatTfloat PhysicalFunction nes-physical-operators AddFloatTfloatPhysicalFunction.cpp) add_plugin(AddTfloatFloat PhysicalFunction nes-physical-operators AddTfloatFloatPhysicalFunction.cpp) +add_plugin(AddBigintTbigint PhysicalFunction nes-physical-operators AddBigintTbigintPhysicalFunction.cpp) add_plugin(AddTbigintBigint PhysicalFunction nes-physical-operators AddTbigintBigintPhysicalFunction.cpp) add_plugin(AddIntTint PhysicalFunction nes-physical-operators AddIntTintPhysicalFunction.cpp) add_plugin(AddTintInt PhysicalFunction nes-physical-operators AddTintIntPhysicalFunction.cpp) @@ -36,14 +37,17 @@ add_plugin(TemporalRound PhysicalFunction nes-physical-operators TemporalRoundPh add_plugin(TintScaleValue PhysicalFunction nes-physical-operators TintScaleValuePhysicalFunction.cpp) add_plugin(TintShiftScaleValue PhysicalFunction nes-physical-operators TintShiftScaleValuePhysicalFunction.cpp) add_plugin(TintShiftValue PhysicalFunction nes-physical-operators TintShiftValuePhysicalFunction.cpp) +add_plugin(DivBigintTbigint PhysicalFunction nes-physical-operators DivBigintTbigintPhysicalFunction.cpp) add_plugin(DivTbigintBigint PhysicalFunction nes-physical-operators DivTbigintBigintPhysicalFunction.cpp) add_plugin(DivIntTint PhysicalFunction nes-physical-operators DivIntTintPhysicalFunction.cpp) add_plugin(DivTintInt PhysicalFunction nes-physical-operators DivTintIntPhysicalFunction.cpp) add_plugin(DivTnumberTnumber PhysicalFunction nes-physical-operators DivTnumberTnumberPhysicalFunction.cpp) +add_plugin(MulBigintTbigint PhysicalFunction nes-physical-operators MulBigintTbigintPhysicalFunction.cpp) add_plugin(MulTbigintBigint PhysicalFunction nes-physical-operators MulTbigintBigintPhysicalFunction.cpp) add_plugin(MulIntTint PhysicalFunction nes-physical-operators MulIntTintPhysicalFunction.cpp) add_plugin(MulTintInt PhysicalFunction nes-physical-operators MulTintIntPhysicalFunction.cpp) add_plugin(MulTnumberTnumber PhysicalFunction nes-physical-operators MulTnumberTnumberPhysicalFunction.cpp) +add_plugin(SubBigintTbigint PhysicalFunction nes-physical-operators SubBigintTbigintPhysicalFunction.cpp) add_plugin(SubTbigintBigint PhysicalFunction nes-physical-operators SubTbigintBigintPhysicalFunction.cpp) add_plugin(SubIntTint PhysicalFunction nes-physical-operators SubIntTintPhysicalFunction.cpp) add_plugin(SubTintInt PhysicalFunction nes-physical-operators SubTintIntPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/DivBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/DivBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..5d79d2132b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/DivBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +DivBigintTbigintPhysicalFunction::DivBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal DivBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double scalar_d, double value_d, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value_d), + MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = div_bigint_tbigint(static_cast(scalar_d), temp); + free(temp); + if (!res) return 0.0; + double r = static_cast(tbigint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterDivBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "DivBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return DivBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/MulBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/MulBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..0919846d1d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/MulBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +MulBigintTbigintPhysicalFunction::MulBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal MulBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double scalar_d, double value_d, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value_d), + MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = mul_bigint_tbigint(static_cast(scalar_d), temp); + free(temp); + if (!res) return 0.0; + double r = static_cast(tbigint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterMulBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "MulBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return MulBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/SubBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/SubBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..a6331aec84 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/SubBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +SubBigintTbigintPhysicalFunction::SubBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal SubBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double scalar_d, double value_d, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value_d), + MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = sub_bigint_tbigint(static_cast(scalar_d), temp); + free(temp); + if (!res) return 0.0; + double r = static_cast(tbigint_start_value(res)); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterSubBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "SubBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return SubBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index e38329c1d3..b65b957e47 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -488,24 +488,28 @@ TEMPORAL_AINTERSECTS_GEOMETRY: 'TEMPORAL_AINTERSECTS_GEOMETRY' | 'temporal_ainte TEMPORAL_ECONTAINS_GEOMETRY: 'TEMPORAL_ECONTAINS_GEOMETRY' | 'temporal_econtains_geometry'; EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; TGEO_AT_STBOX: 'TGEO_AT_STBOX' | 'tgeo_at_stbox'; +ADD_BIGINT_TBIGINT: 'ADD_BIGINT_TBIGINT' | 'add_bigint_tbigint'; ADD_FLOAT_TFLOAT: 'ADD_FLOAT_TFLOAT' | 'add_float_tfloat'; ADD_TBIGINT_BIGINT: 'ADD_TBIGINT_BIGINT' | 'add_tbigint_bigint'; ADD_TFLOAT_FLOAT: 'ADD_TFLOAT_FLOAT' | 'add_tfloat_float'; ADD_INT_TINT: 'ADD_INT_TINT' | 'add_int_tint'; ADD_TINT_INT: 'ADD_TINT_INT' | 'add_tint_int'; ADD_TNUMBER_TNUMBER: 'ADD_TNUMBER_TNUMBER' | 'add_tnumber_tnumber'; +DIV_BIGINT_TBIGINT: 'DIV_BIGINT_TBIGINT' | 'div_bigint_tbigint'; DIV_FLOAT_TFLOAT: 'DIV_FLOAT_TFLOAT' | 'div_float_tfloat'; DIV_TBIGINT_BIGINT: 'DIV_TBIGINT_BIGINT' | 'div_tbigint_bigint'; DIV_TFLOAT_FLOAT: 'DIV_TFLOAT_FLOAT' | 'div_tfloat_float'; DIV_INT_TINT: 'DIV_INT_TINT' | 'div_int_tint'; DIV_TINT_INT: 'DIV_TINT_INT' | 'div_tint_int'; DIV_TNUMBER_TNUMBER: 'DIV_TNUMBER_TNUMBER' | 'div_tnumber_tnumber'; +MUL_BIGINT_TBIGINT: 'MUL_BIGINT_TBIGINT' | 'mul_bigint_tbigint'; MUL_FLOAT_TFLOAT: 'MUL_FLOAT_TFLOAT' | 'mul_float_tfloat'; MUL_TBIGINT_BIGINT: 'MUL_TBIGINT_BIGINT' | 'mul_tbigint_bigint'; MUL_TFLOAT_FLOAT: 'MUL_TFLOAT_FLOAT' | 'mul_tfloat_float'; MUL_INT_TINT: 'MUL_INT_TINT' | 'mul_int_tint'; MUL_TINT_INT: 'MUL_TINT_INT' | 'mul_tint_int'; MUL_TNUMBER_TNUMBER: 'MUL_TNUMBER_TNUMBER' | 'mul_tnumber_tnumber'; +SUB_BIGINT_TBIGINT: 'SUB_BIGINT_TBIGINT' | 'sub_bigint_tbigint'; SUB_FLOAT_TFLOAT: 'SUB_FLOAT_TFLOAT' | 'sub_float_tfloat'; SUB_TBIGINT_BIGINT: 'SUB_TBIGINT_BIGINT' | 'sub_tbigint_bigint'; SUB_TFLOAT_FLOAT: 'SUB_TFLOAT_FLOAT' | 'sub_tfloat_float'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index c7666a5cdc..f14eea84b1 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -69,24 +69,28 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -1838,6 +1842,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: SUB_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ADD_BIGINT_TBIGINT */ + case AntlrSQLLexer::ADD_BIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ADD_BIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AddBigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ADD_BIGINT_TBIGINT */ /* BEGIN CODEGEN PARSER GLUE: ADD_TBIGINT_BIGINT */ case AntlrSQLLexer::ADD_TBIGINT_BIGINT: { @@ -1925,6 +1958,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: ADD_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: DIV_BIGINT_TBIGINT */ + case AntlrSQLLexer::DIV_BIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("DIV_BIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(DivBigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: DIV_BIGINT_TBIGINT */ /* BEGIN CODEGEN PARSER GLUE: DIV_TBIGINT_BIGINT */ case AntlrSQLLexer::DIV_TBIGINT_BIGINT: { @@ -2012,6 +2074,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: DIV_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: MUL_BIGINT_TBIGINT */ + case AntlrSQLLexer::MUL_BIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("MUL_BIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(MulBigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: MUL_BIGINT_TBIGINT */ /* BEGIN CODEGEN PARSER GLUE: MUL_TBIGINT_BIGINT */ case AntlrSQLLexer::MUL_TBIGINT_BIGINT: { @@ -2099,6 +2190,35 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: MUL_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: SUB_BIGINT_TBIGINT */ + case AntlrSQLLexer::SUB_BIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("SUB_BIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(SubBigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: SUB_BIGINT_TBIGINT */ /* BEGIN CODEGEN PARSER GLUE: SUB_TBIGINT_BIGINT */ case AntlrSQLLexer::SUB_TBIGINT_BIGINT: { From 5d3a3c92e6860f667f8b2977c57ab73172493fbb Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 08:34:22 +0200 Subject: [PATCH 18/86] feat(meos): add TFLOAT_EXP, TFLOAT_LN, TFLOAT_LOG10 NES operators (W60) Adds per-event scalar NES operators for exponential and logarithmic functions on tfloat temporals: TFLOAT_EXP, TFLOAT_LN, TFLOAT_LOG10. Each operator takes (value:float, ts:uint64) and delegates to the corresponding MEOS tfloat_exp / tfloat_ln / tfloat_log10 kernel. --- .../Meos/TfloatExpLogicalFunction.hpp | 53 +++++++++ .../Meos/TfloatLnLogicalFunction.hpp | 53 +++++++++ .../Meos/TfloatLog10LogicalFunction.hpp | 53 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../Meos/TfloatExpLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/TfloatLnLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/TfloatLog10LogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/TfloatExpPhysicalFunction.hpp | 42 ++++++++ .../Meos/TfloatLnPhysicalFunction.hpp | 42 ++++++++ .../Meos/TfloatLog10PhysicalFunction.hpp | 42 ++++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../Meos/TfloatExpPhysicalFunction.cpp | 87 +++++++++++++++ .../Meos/TfloatLnPhysicalFunction.cpp | 87 +++++++++++++++ .../Meos/TfloatLog10PhysicalFunction.cpp | 87 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 5 +- .../src/AntlrSQLQueryPlanCreator.cpp | 87 +++++++++++++++ 16 files changed, 949 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatExpLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatLnLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TfloatLog10LogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatExpLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatLnLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TfloatLog10LogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatExpPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatLnPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TfloatLog10PhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatExpPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatLnPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TfloatLog10PhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TfloatExpLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatExpLogicalFunction.hpp new file mode 100644 index 0000000000..a006015a7b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatExpLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_exp: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_exp`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TfloatExpLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatExp"; + + TfloatExpLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TfloatLnLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatLnLogicalFunction.hpp new file mode 100644 index 0000000000..2924cce5ff --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatLnLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_ln: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_ln`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TfloatLnLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatLn"; + + TfloatLnLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TfloatLog10LogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TfloatLog10LogicalFunction.hpp new file mode 100644 index 0000000000..0b3703d878 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TfloatLog10LogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tfloat_log10: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tfloat_log10`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TfloatLog10LogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TfloatLog10"; + + TfloatLog10LogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index a99de0cdb4..269767f962 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -21,7 +21,10 @@ add_plugin(TemporalAtStBox LogicalFunction nes-logical-operators TemporalAtStBox add_plugin(TfloatCeil LogicalFunction nes-logical-operators TfloatCeilLogicalFunction.cpp) add_plugin(TfloatCos LogicalFunction nes-logical-operators TfloatCosLogicalFunction.cpp) add_plugin(TfloatDegrees LogicalFunction nes-logical-operators TfloatDegreesLogicalFunction.cpp) +add_plugin(TfloatExp LogicalFunction nes-logical-operators TfloatExpLogicalFunction.cpp) add_plugin(TfloatFloor LogicalFunction nes-logical-operators TfloatFloorLogicalFunction.cpp) +add_plugin(TfloatLn LogicalFunction nes-logical-operators TfloatLnLogicalFunction.cpp) +add_plugin(TfloatLog10 LogicalFunction nes-logical-operators TfloatLog10LogicalFunction.cpp) add_plugin(TfloatRadians LogicalFunction nes-logical-operators TfloatRadiansLogicalFunction.cpp) add_plugin(TfloatScaleValue LogicalFunction nes-logical-operators TfloatScaleValueLogicalFunction.cpp) add_plugin(AddFloatTfloat LogicalFunction nes-logical-operators AddFloatTfloatLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TfloatExpLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatExpLogicalFunction.cpp new file mode 100644 index 0000000000..bf6a97e365 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatExpLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatExpLogicalFunction::TfloatExpLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TfloatExpLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatExpLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatExpLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatExpLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TfloatExpLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatExpLogicalFunction::getType() const { return NAME; } + +bool TfloatExpLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatExpLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatExpLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatExpLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatExpLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TfloatExpLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TfloatExpLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TfloatLnLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatLnLogicalFunction.cpp new file mode 100644 index 0000000000..2d12b9baa5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatLnLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatLnLogicalFunction::TfloatLnLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TfloatLnLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatLnLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatLnLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatLnLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TfloatLnLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatLnLogicalFunction::getType() const { return NAME; } + +bool TfloatLnLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatLnLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatLnLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatLnLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatLnLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TfloatLnLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TfloatLnLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TfloatLog10LogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TfloatLog10LogicalFunction.cpp new file mode 100644 index 0000000000..22fe17e9ba --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TfloatLog10LogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TfloatLog10LogicalFunction::TfloatLog10LogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TfloatLog10LogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TfloatLog10LogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TfloatLog10LogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TfloatLog10LogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TfloatLog10LogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TfloatLog10LogicalFunction::getType() const { return NAME; } + +bool TfloatLog10LogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TfloatLog10LogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TfloatLog10LogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TfloatLog10LogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTfloatLog10LogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TfloatLog10LogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TfloatLog10LogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatExpPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatExpPhysicalFunction.hpp new file mode 100644 index 0000000000..3f4c0e84be --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatExpPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_exp`. + * + * Per-event tfloat_exp: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatExpPhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatExpPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatLnPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatLnPhysicalFunction.hpp new file mode 100644 index 0000000000..e2539cd8f5 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatLnPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_ln`. + * + * Per-event tfloat_ln: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatLnPhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatLnPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TfloatLog10PhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TfloatLog10PhysicalFunction.hpp new file mode 100644 index 0000000000..47439e84e8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TfloatLog10PhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tfloat_log10`. + * + * Per-event tfloat_log10: single-instant tfloat transform, value extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TfloatLog10PhysicalFunction : public PhysicalFunctionConcept { +public: + TfloatLog10PhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 036d4bdf7d..36c772b8d9 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -20,7 +20,10 @@ add_plugin(TemporalAtStBox PhysicalFunction nes-physical-operators TemporalAtStB add_plugin(TfloatCeil PhysicalFunction nes-physical-operators TfloatCeilPhysicalFunction.cpp) add_plugin(TfloatCos PhysicalFunction nes-physical-operators TfloatCosPhysicalFunction.cpp) add_plugin(TfloatDegrees PhysicalFunction nes-physical-operators TfloatDegreesPhysicalFunction.cpp) +add_plugin(TfloatExp PhysicalFunction nes-physical-operators TfloatExpPhysicalFunction.cpp) add_plugin(TfloatFloor PhysicalFunction nes-physical-operators TfloatFloorPhysicalFunction.cpp) +add_plugin(TfloatLn PhysicalFunction nes-physical-operators TfloatLnPhysicalFunction.cpp) +add_plugin(TfloatLog10 PhysicalFunction nes-physical-operators TfloatLog10PhysicalFunction.cpp) add_plugin(TfloatRadians PhysicalFunction nes-physical-operators TfloatRadiansPhysicalFunction.cpp) add_plugin(TfloatScaleValue PhysicalFunction nes-physical-operators TfloatScaleValuePhysicalFunction.cpp) add_plugin(AddFloatTfloat PhysicalFunction nes-physical-operators AddFloatTfloatPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/TfloatExpPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatExpPhysicalFunction.cpp new file mode 100644 index 0000000000..be30a495cc --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatExpPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatExpPhysicalFunction::TfloatExpPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TfloatExpPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_exp(temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatExpPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TfloatExpPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TfloatExpPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TfloatLnPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatLnPhysicalFunction.cpp new file mode 100644 index 0000000000..78550610c8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatLnPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatLnPhysicalFunction::TfloatLnPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TfloatLnPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_ln(temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatLnPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TfloatLnPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TfloatLnPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TfloatLog10PhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TfloatLog10PhysicalFunction.cpp new file mode 100644 index 0000000000..59fba49cc9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TfloatLog10PhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TfloatLog10PhysicalFunction::TfloatLog10PhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TfloatLog10PhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double value, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tfloat_log10(temp); + free(temp); + if (!res) return 0.0; + double r = tfloat_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTfloatLog10PhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TfloatLog10PhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TfloatLog10PhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index b65b957e47..141cb35cf1 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_FLOOR | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -528,7 +528,10 @@ TEMPORAL_ROUND: 'TEMPORAL_ROUND' | 'temporal_round'; TFLOAT_CEIL: 'TFLOAT_CEIL' | 'tfloat_ceil'; TFLOAT_COS: 'TFLOAT_COS' | 'tfloat_cos'; TFLOAT_DEGREES: 'TFLOAT_DEGREES' | 'tfloat_degrees'; +TFLOAT_EXP: 'TFLOAT_EXP' | 'tfloat_exp'; TFLOAT_FLOOR: 'TFLOAT_FLOOR' | 'tfloat_floor'; +TFLOAT_LN: 'TFLOAT_LN' | 'tfloat_ln'; +TFLOAT_LOG10: 'TFLOAT_LOG10' | 'tfloat_log10'; TFLOAT_RADIANS: 'TFLOAT_RADIANS' | 'tfloat_radians'; TFLOAT_SCALE_VALUE: 'TFLOAT_SCALE_VALUE' | 'tfloat_scale_value'; TFLOAT_SHIFT_SCALE_VALUE: 'TFLOAT_SHIFT_SCALE_VALUE' | 'tfloat_shift_scale_value'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index f14eea84b1..e5d23de442 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -109,7 +109,10 @@ #include #include #include +#include #include +#include +#include #include #include #include @@ -1438,6 +1441,34 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TFLOAT_DEGREES */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_EXP */ + case AntlrSQLLexer::TFLOAT_EXP: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TFLOAT_EXP requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatExpLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_EXP */ /* BEGIN CODEGEN PARSER GLUE: TFLOAT_FLOOR */ case AntlrSQLLexer::TFLOAT_FLOOR: { @@ -1466,6 +1497,62 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TFLOAT_FLOOR */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_LN */ + case AntlrSQLLexer::TFLOAT_LN: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TFLOAT_LN requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatLnLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_LN */ + /* BEGIN CODEGEN PARSER GLUE: TFLOAT_LOG10 */ + case AntlrSQLLexer::TFLOAT_LOG10: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TFLOAT_LOG10 requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TfloatLog10LogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TFLOAT_LOG10 */ /* BEGIN CODEGEN PARSER GLUE: TFLOAT_RADIANS */ case AntlrSQLLexer::TFLOAT_RADIANS: { From 367ebadf9c23316f0775f373d3f76739a976b29c Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 08:43:23 +0200 Subject: [PATCH 19/86] feat(meos): add EVER_EQ/GE/GT/LE/LT/NE_TFLOAT_FLOAT NES operators (W61) Adds six per-event ever-comparison scalar operators for tfloat against a float threshold: EVER_EQ_TFLOAT_FLOAT, EVER_GE_TFLOAT_FLOAT, EVER_GT_TFLOAT_FLOAT, EVER_LE_TFLOAT_FLOAT, EVER_LT_TFLOAT_FLOAT, EVER_NE_TFLOAT_FLOAT. Each operator constructs a single-instant tfloat from (value, ts), calls the corresponding MEOS ever_*_tfloat_float kernel returning int, and emits the result as double. Logical and physical function pairs, CMakeLists plugin registrations, AntlrSQL grammar tokens, and AntlrSQLQueryPlanCreator case blocks are included. --- .../Meos/EverEqTfloatFloatLogicalFunction.hpp | 54 ++++++ .../Meos/EverGeTfloatFloatLogicalFunction.hpp | 54 ++++++ .../Meos/EverGtTfloatFloatLogicalFunction.hpp | 54 ++++++ .../Meos/EverLeTfloatFloatLogicalFunction.hpp | 54 ++++++ .../Meos/EverLtTfloatFloatLogicalFunction.hpp | 54 ++++++ .../Meos/EverNeTfloatFloatLogicalFunction.hpp | 54 ++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../Meos/EverEqTfloatFloatLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverGeTfloatFloatLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverGtTfloatFloatLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverLeTfloatFloatLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverLtTfloatFloatLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverNeTfloatFloatLogicalFunction.cpp | 105 ++++++++++ .../EverEqTfloatFloatPhysicalFunction.hpp | 43 +++++ .../EverGeTfloatFloatPhysicalFunction.hpp | 43 +++++ .../EverGtTfloatFloatPhysicalFunction.hpp | 43 +++++ .../EverLeTfloatFloatPhysicalFunction.hpp | 43 +++++ .../EverLtTfloatFloatPhysicalFunction.hpp | 43 +++++ .../EverNeTfloatFloatPhysicalFunction.hpp | 43 +++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../EverEqTfloatFloatPhysicalFunction.cpp | 88 +++++++++ .../EverGeTfloatFloatPhysicalFunction.cpp | 88 +++++++++ .../EverGtTfloatFloatPhysicalFunction.cpp | 88 +++++++++ .../EverLeTfloatFloatPhysicalFunction.cpp | 88 +++++++++ .../EverLtTfloatFloatPhysicalFunction.cpp | 88 +++++++++ .../EverNeTfloatFloatPhysicalFunction.cpp | 88 +++++++++ nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 180 ++++++++++++++++++ 28 files changed, 1939 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGeTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGtTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLeTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLtTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGeTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGtTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLeTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLtTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTfloatFloatLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGeTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGtTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLeTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLtTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGeTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGtTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLeTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLtTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTfloatFloatPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..c70acdbb92 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_eq_tfloat_float: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_eq_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverEqTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTfloatFloat"; + + EverEqTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGeTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..22b39d8182 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGeTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ge_tfloat_float: tests if a single-instant tfloat value is ever >= a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ge_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGeTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGeTfloatFloat"; + + EverGeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGtTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..52f96894e9 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGtTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_gt_tfloat_float: tests if a single-instant tfloat value is ever > a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_gt_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGtTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGtTfloatFloat"; + + EverGtTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLeTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..ac1bc8a633 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLeTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_le_tfloat_float: tests if a single-instant tfloat value is ever <= a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_le_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLeTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLeTfloatFloat"; + + EverLeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLtTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..599a583fb2 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLtTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_lt_tfloat_float: tests if a single-instant tfloat value is ever < a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_lt_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLtTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLtTfloatFloat"; + + EverLtTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..08568d04ac --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ne_tfloat_float: tests if a single-instant tfloat value ever differs from a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ne_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverNeTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTfloatFloat"; + + EverNeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 269767f962..0c35460553 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -76,3 +76,9 @@ add_plugin(TfloatToTint LogicalFunction nes-logical-operators TfloatToTintLogica add_plugin(TintToTbigint LogicalFunction nes-logical-operators TintToTbigintLogicalFunction.cpp) add_plugin(TintToTfloat LogicalFunction nes-logical-operators TintToTfloatLogicalFunction.cpp) add_plugin(TnumberAbs LogicalFunction nes-logical-operators TnumberAbsLogicalFunction.cpp) +add_plugin(EverEqTfloatFloat LogicalFunction nes-logical-operators EverEqTfloatFloatLogicalFunction.cpp) +add_plugin(EverGeTfloatFloat LogicalFunction nes-logical-operators EverGeTfloatFloatLogicalFunction.cpp) +add_plugin(EverGtTfloatFloat LogicalFunction nes-logical-operators EverGtTfloatFloatLogicalFunction.cpp) +add_plugin(EverLeTfloatFloat LogicalFunction nes-logical-operators EverLeTfloatFloatLogicalFunction.cpp) +add_plugin(EverLtTfloatFloat LogicalFunction nes-logical-operators EverLtTfloatFloatLogicalFunction.cpp) +add_plugin(EverNeTfloatFloat LogicalFunction nes-logical-operators EverNeTfloatFloatLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..58a752c660 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTfloatFloatLogicalFunction::EverEqTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverEqTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool EverEqTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverEqTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverEqTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverEqTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..c5e65c1630 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGeTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGeTfloatFloatLogicalFunction::EverGeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGeTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGeTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGeTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGeTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGeTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGeTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool EverGeTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGeTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGeTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGeTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGeTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGeTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..59d09da9f5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGtTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGtTfloatFloatLogicalFunction::EverGtTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGtTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGtTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGtTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGtTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGtTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGtTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool EverGtTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGtTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGtTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGtTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGtTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGtTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..d8da3f26e7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLeTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLeTfloatFloatLogicalFunction::EverLeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLeTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLeTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLeTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLeTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLeTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLeTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool EverLeTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLeTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLeTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLeTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLeTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLeTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..4dec444034 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLtTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLtTfloatFloatLogicalFunction::EverLtTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLtTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLtTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLtTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLtTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLtTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLtTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool EverLtTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLtTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLtTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLtTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLtTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLtTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..5ce1fbdbb9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTfloatFloatLogicalFunction::EverNeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverNeTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool EverNeTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverNeTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverNeTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverNeTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..6a639a7d81 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_eq_tfloat_float`. + * + * Per-event ever_eq_tfloat_float: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverEqTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGeTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..71be2abc10 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGeTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ge_tfloat_float`. + * + * Per-event ever_ge_tfloat_float: tests if a single-instant tfloat value is ever >= a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGeTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGtTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..1d16f7234f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGtTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_gt_tfloat_float`. + * + * Per-event ever_gt_tfloat_float: tests if a single-instant tfloat value is ever > a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGtTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGtTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLeTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..6b2c963040 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLeTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_le_tfloat_float`. + * + * Per-event ever_le_tfloat_float: tests if a single-instant tfloat value is ever <= a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLeTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLtTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..cc393311c9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLtTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_lt_tfloat_float`. + * + * Per-event ever_lt_tfloat_float: tests if a single-instant tfloat value is ever < a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLtTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLtTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..61ae514722 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ne_tfloat_float`. + * + * Per-event ever_ne_tfloat_float: tests if a single-instant tfloat value ever differs from a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverNeTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 36c772b8d9..43cddd97b6 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -75,4 +75,10 @@ add_plugin(TfloatToTint PhysicalFunction nes-physical-operators TfloatToTintPhys add_plugin(TintToTbigint PhysicalFunction nes-physical-operators TintToTbigintPhysicalFunction.cpp) add_plugin(TintToTfloat PhysicalFunction nes-physical-operators TintToTfloatPhysicalFunction.cpp) add_plugin(TnumberAbs PhysicalFunction nes-physical-operators TnumberAbsPhysicalFunction.cpp) +add_plugin(EverEqTfloatFloat PhysicalFunction nes-physical-operators EverEqTfloatFloatPhysicalFunction.cpp) +add_plugin(EverGeTfloatFloat PhysicalFunction nes-physical-operators EverGeTfloatFloatPhysicalFunction.cpp) +add_plugin(EverGtTfloatFloat PhysicalFunction nes-physical-operators EverGtTfloatFloatPhysicalFunction.cpp) +add_plugin(EverLeTfloatFloat PhysicalFunction nes-physical-operators EverLeTfloatFloatPhysicalFunction.cpp) +add_plugin(EverLtTfloatFloat PhysicalFunction nes-physical-operators EverLtTfloatFloatPhysicalFunction.cpp) +add_plugin(EverNeTfloatFloat PhysicalFunction nes-physical-operators EverNeTfloatFloatPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..86aa083ad2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTfloatFloatPhysicalFunction::EverEqTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverEqTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_eq_tfloat_float(temp, threshold); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverEqTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGeTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..d234284498 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGeTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGeTfloatFloatPhysicalFunction::EverGeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGeTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_ge_tfloat_float(temp, threshold); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGeTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGeTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGeTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGtTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..a8ba01257d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGtTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGtTfloatFloatPhysicalFunction::EverGtTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGtTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_gt_tfloat_float(temp, threshold); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGtTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGtTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGtTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLeTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..2724078153 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLeTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLeTfloatFloatPhysicalFunction::EverLeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLeTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_le_tfloat_float(temp, threshold); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLeTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLeTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLeTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLtTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..7717a654f2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLtTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLtTfloatFloatPhysicalFunction::EverLtTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLtTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_lt_tfloat_float(temp, threshold); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLtTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLtTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLtTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..681b87ea0e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTfloatFloatPhysicalFunction::EverNeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverNeTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_ne_tfloat_float(temp, threshold); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverNeTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 141cb35cf1..ec195f471d 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -487,6 +487,12 @@ TEMPORAL_EINTERSECTS_GEOMETRY: 'TEMPORAL_EINTERSECTS_GEOMETRY' | 'temporal_einte TEMPORAL_AINTERSECTS_GEOMETRY: 'TEMPORAL_AINTERSECTS_GEOMETRY' | 'temporal_aintersects_geometry'; TEMPORAL_ECONTAINS_GEOMETRY: 'TEMPORAL_ECONTAINS_GEOMETRY' | 'temporal_econtains_geometry'; EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; +EVER_EQ_TFLOAT_FLOAT: 'EVER_EQ_TFLOAT_FLOAT' | 'ever_eq_tfloat_float'; +EVER_GE_TFLOAT_FLOAT: 'EVER_GE_TFLOAT_FLOAT' | 'ever_ge_tfloat_float'; +EVER_GT_TFLOAT_FLOAT: 'EVER_GT_TFLOAT_FLOAT' | 'ever_gt_tfloat_float'; +EVER_LE_TFLOAT_FLOAT: 'EVER_LE_TFLOAT_FLOAT' | 'ever_le_tfloat_float'; +EVER_LT_TFLOAT_FLOAT: 'EVER_LT_TFLOAT_FLOAT' | 'ever_lt_tfloat_float'; +EVER_NE_TFLOAT_FLOAT: 'EVER_NE_TFLOAT_FLOAT' | 'ever_ne_tfloat_float'; TGEO_AT_STBOX: 'TGEO_AT_STBOX' | 'tgeo_at_stbox'; ADD_BIGINT_TBIGINT: 'ADD_BIGINT_TBIGINT' | 'add_bigint_tbigint'; ADD_FLOAT_TFLOAT: 'ADD_FLOAT_TFLOAT' | 'add_float_tfloat'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index e5d23de442..545ac88c27 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -127,6 +127,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -2914,6 +2920,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TINT_TO_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TFLOAT_FLOAT */ + case AntlrSQLLexer::EVER_EQ_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GE_TFLOAT_FLOAT */ + case AntlrSQLLexer::EVER_GE_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GE_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGeTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GE_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GT_TFLOAT_FLOAT */ + case AntlrSQLLexer::EVER_GT_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GT_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGtTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GT_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LE_TFLOAT_FLOAT */ + case AntlrSQLLexer::EVER_LE_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LE_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLeTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LE_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LT_TFLOAT_FLOAT */ + case AntlrSQLLexer::EVER_LT_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LT_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLtTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LT_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_TFLOAT_FLOAT */ + case AntlrSQLLexer::EVER_NE_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_NE_TFLOAT_FLOAT */ default: /// Check if the function is a constructor for a datatype From 2c9998dec9fb03bdbac655d15643b028c21b5eb9 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 08:50:09 +0200 Subject: [PATCH 20/86] feat(meos): add ALWAYS_EQ/GE/GT/LE/LT/NE_TFLOAT_FLOAT NES operators (W62) Adds six per-event always-comparison scalar operators for tfloat against a float threshold: ALWAYS_EQ_TFLOAT_FLOAT, ALWAYS_GE_TFLOAT_FLOAT, ALWAYS_GT_TFLOAT_FLOAT, ALWAYS_LE_TFLOAT_FLOAT, ALWAYS_LT_TFLOAT_FLOAT, ALWAYS_NE_TFLOAT_FLOAT. Each operator constructs a single-instant tfloat from (value, ts), calls the corresponding MEOS always_*_tfloat_float kernel returning int, and emits the result as double. Logical and physical function pairs, CMakeLists plugin registrations, AntlrSQL grammar tokens, and AntlrSQLQueryPlanCreator case blocks are included. --- .../AlwaysEqTfloatFloatLogicalFunction.hpp | 54 ++++++ .../AlwaysGeTfloatFloatLogicalFunction.hpp | 54 ++++++ .../AlwaysGtTfloatFloatLogicalFunction.hpp | 54 ++++++ .../AlwaysLeTfloatFloatLogicalFunction.hpp | 54 ++++++ .../AlwaysLtTfloatFloatLogicalFunction.hpp | 54 ++++++ .../AlwaysNeTfloatFloatLogicalFunction.hpp | 54 ++++++ .../AlwaysEqTfloatFloatLogicalFunction.cpp | 105 ++++++++++ .../AlwaysGeTfloatFloatLogicalFunction.cpp | 105 ++++++++++ .../AlwaysGtTfloatFloatLogicalFunction.cpp | 105 ++++++++++ .../AlwaysLeTfloatFloatLogicalFunction.cpp | 105 ++++++++++ .../AlwaysLtTfloatFloatLogicalFunction.cpp | 105 ++++++++++ .../AlwaysNeTfloatFloatLogicalFunction.cpp | 105 ++++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../AlwaysEqTfloatFloatPhysicalFunction.hpp | 43 +++++ .../AlwaysGeTfloatFloatPhysicalFunction.hpp | 43 +++++ .../AlwaysGtTfloatFloatPhysicalFunction.hpp | 43 +++++ .../AlwaysLeTfloatFloatPhysicalFunction.hpp | 43 +++++ .../AlwaysLtTfloatFloatPhysicalFunction.hpp | 43 +++++ .../AlwaysNeTfloatFloatPhysicalFunction.hpp | 43 +++++ .../AlwaysEqTfloatFloatPhysicalFunction.cpp | 88 +++++++++ .../AlwaysGeTfloatFloatPhysicalFunction.cpp | 88 +++++++++ .../AlwaysGtTfloatFloatPhysicalFunction.cpp | 88 +++++++++ .../AlwaysLeTfloatFloatPhysicalFunction.cpp | 88 +++++++++ .../AlwaysLtTfloatFloatPhysicalFunction.cpp | 88 +++++++++ .../AlwaysNeTfloatFloatPhysicalFunction.cpp | 88 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 180 ++++++++++++++++++ 28 files changed, 1939 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGeTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGtTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLeTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLtTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGeTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGtTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLeTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLtTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTfloatFloatLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGeTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGtTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLeTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLtTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGeTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGtTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLeTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLtTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTfloatFloatPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..4feb84d46e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_eq_tfloat_float: tests if a single-instant tfloat value always equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_eq_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysEqTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTfloatFloat"; + + AlwaysEqTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..a7ef047a6b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ge_tfloat_float: tests if a single-instant tfloat value always is greater than or equal to a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ge_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGeTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGeTfloatFloat"; + + AlwaysGeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..f85e4558e1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_gt_tfloat_float: tests if a single-instant tfloat value always is greater than a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_gt_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGtTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGtTfloatFloat"; + + AlwaysGtTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..1ce49d77a7 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_le_tfloat_float: tests if a single-instant tfloat value always is less than or equal to a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_le_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLeTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLeTfloatFloat"; + + AlwaysLeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..fbf9801378 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_lt_tfloat_float: tests if a single-instant tfloat value always is less than a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_lt_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLtTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLtTfloatFloat"; + + AlwaysLtTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..7a80868519 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ne_tfloat_float: tests if a single-instant tfloat value always is not equal to a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ne_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysNeTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTfloatFloat"; + + AlwaysNeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..d7a01dae71 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTfloatFloatLogicalFunction::AlwaysEqTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysEqTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysEqTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysEqTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysEqTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..712d202b14 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGeTfloatFloatLogicalFunction::AlwaysGeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGeTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGeTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGeTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGeTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGeTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGeTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysGeTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGeTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGeTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGeTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGeTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGeTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..8edb267dca --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGtTfloatFloatLogicalFunction::AlwaysGtTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGtTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGtTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGtTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGtTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGtTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGtTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysGtTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGtTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGtTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGtTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGtTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGtTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..95d2c44151 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLeTfloatFloatLogicalFunction::AlwaysLeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLeTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLeTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLeTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLeTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLeTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLeTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysLeTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLeTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLeTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLeTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLeTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLeTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..44fedc6124 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLtTfloatFloatLogicalFunction::AlwaysLtTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLtTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLtTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLtTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLtTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLtTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLtTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysLtTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLtTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLtTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLtTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLtTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLtTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..fab1dbb741 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTfloatFloatLogicalFunction::AlwaysNeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysNeTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysNeTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysNeTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysNeTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 0c35460553..f80fb56ab9 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -82,3 +82,9 @@ add_plugin(EverGtTfloatFloat LogicalFunction nes-logical-operators EverGtTfloatF add_plugin(EverLeTfloatFloat LogicalFunction nes-logical-operators EverLeTfloatFloatLogicalFunction.cpp) add_plugin(EverLtTfloatFloat LogicalFunction nes-logical-operators EverLtTfloatFloatLogicalFunction.cpp) add_plugin(EverNeTfloatFloat LogicalFunction nes-logical-operators EverNeTfloatFloatLogicalFunction.cpp) +add_plugin(AlwaysEqTfloatFloat LogicalFunction nes-logical-operators AlwaysEqTfloatFloatLogicalFunction.cpp) +add_plugin(AlwaysGeTfloatFloat LogicalFunction nes-logical-operators AlwaysGeTfloatFloatLogicalFunction.cpp) +add_plugin(AlwaysGtTfloatFloat LogicalFunction nes-logical-operators AlwaysGtTfloatFloatLogicalFunction.cpp) +add_plugin(AlwaysLeTfloatFloat LogicalFunction nes-logical-operators AlwaysLeTfloatFloatLogicalFunction.cpp) +add_plugin(AlwaysLtTfloatFloat LogicalFunction nes-logical-operators AlwaysLtTfloatFloatLogicalFunction.cpp) +add_plugin(AlwaysNeTfloatFloat LogicalFunction nes-logical-operators AlwaysNeTfloatFloatLogicalFunction.cpp) diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..0e439990e7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_eq_tfloat_float`. + * + * Per-event always_eq_tfloat_float: tests if a single-instant tfloat value always equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysEqTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..4bda09b03d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ge_tfloat_float`. + * + * Per-event always_ge_tfloat_float: tests if a single-instant tfloat value always is greater than or equal to a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGeTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..7272583f06 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_gt_tfloat_float`. + * + * Per-event always_gt_tfloat_float: tests if a single-instant tfloat value always is greater than a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGtTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGtTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..38e9384ce4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_le_tfloat_float`. + * + * Per-event always_le_tfloat_float: tests if a single-instant tfloat value always is less than or equal to a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLeTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..bce18200bf --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_lt_tfloat_float`. + * + * Per-event always_lt_tfloat_float: tests if a single-instant tfloat value always is less than a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLtTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLtTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..bb6fd34c50 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ne_tfloat_float`. + * + * Per-event always_ne_tfloat_float: tests if a single-instant tfloat value always is not equal to a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysNeTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..d80ba1d066 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTfloatFloatPhysicalFunction::AlwaysEqTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_eq_tfloat_float(temp, threshold); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysEqTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..58d7b4dfa2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGeTfloatFloatPhysicalFunction::AlwaysGeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGeTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_ge_tfloat_float(temp, threshold); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGeTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGeTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGeTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..734a308e51 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGtTfloatFloatPhysicalFunction::AlwaysGtTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGtTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_gt_tfloat_float(temp, threshold); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGtTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGtTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGtTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..8fbcab93d5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLeTfloatFloatPhysicalFunction::AlwaysLeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLeTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_le_tfloat_float(temp, threshold); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLeTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLeTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLeTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..e3c12b1c89 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLtTfloatFloatPhysicalFunction::AlwaysLtTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLtTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_lt_tfloat_float(temp, threshold); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLtTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLtTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLtTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..769c701a99 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTfloatFloatPhysicalFunction::AlwaysNeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", value, MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tfloat_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_ne_tfloat_float(temp, threshold); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysNeTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 43cddd97b6..1cf15e45be 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -81,4 +81,10 @@ add_plugin(EverGtTfloatFloat PhysicalFunction nes-physical-operators EverGtTfloa add_plugin(EverLeTfloatFloat PhysicalFunction nes-physical-operators EverLeTfloatFloatPhysicalFunction.cpp) add_plugin(EverLtTfloatFloat PhysicalFunction nes-physical-operators EverLtTfloatFloatPhysicalFunction.cpp) add_plugin(EverNeTfloatFloat PhysicalFunction nes-physical-operators EverNeTfloatFloatPhysicalFunction.cpp) +add_plugin(AlwaysEqTfloatFloat PhysicalFunction nes-physical-operators AlwaysEqTfloatFloatPhysicalFunction.cpp) +add_plugin(AlwaysGeTfloatFloat PhysicalFunction nes-physical-operators AlwaysGeTfloatFloatPhysicalFunction.cpp) +add_plugin(AlwaysGtTfloatFloat PhysicalFunction nes-physical-operators AlwaysGtTfloatFloatPhysicalFunction.cpp) +add_plugin(AlwaysLeTfloatFloat PhysicalFunction nes-physical-operators AlwaysLeTfloatFloatPhysicalFunction.cpp) +add_plugin(AlwaysLtTfloatFloat PhysicalFunction nes-physical-operators AlwaysLtTfloatFloatPhysicalFunction.cpp) +add_plugin(AlwaysNeTfloatFloat PhysicalFunction nes-physical-operators AlwaysNeTfloatFloatPhysicalFunction.cpp) endif() diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index ec195f471d..28cd19856c 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | EDWITHIN_TGEO_GEO | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | EDWITHIN_TGEO_GEO | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -486,6 +486,12 @@ TEMPORAL_SEQUENCE: 'TEMPORAL_SEQUENCE' | 'temporal_sequence'; TEMPORAL_EINTERSECTS_GEOMETRY: 'TEMPORAL_EINTERSECTS_GEOMETRY' | 'temporal_eintersects_geometry'; TEMPORAL_AINTERSECTS_GEOMETRY: 'TEMPORAL_AINTERSECTS_GEOMETRY' | 'temporal_aintersects_geometry'; TEMPORAL_ECONTAINS_GEOMETRY: 'TEMPORAL_ECONTAINS_GEOMETRY' | 'temporal_econtains_geometry'; +ALWAYS_EQ_TFLOAT_FLOAT: 'ALWAYS_EQ_TFLOAT_FLOAT' | 'always_eq_tfloat_float'; +ALWAYS_GE_TFLOAT_FLOAT: 'ALWAYS_GE_TFLOAT_FLOAT' | 'always_ge_tfloat_float'; +ALWAYS_GT_TFLOAT_FLOAT: 'ALWAYS_GT_TFLOAT_FLOAT' | 'always_gt_tfloat_float'; +ALWAYS_LE_TFLOAT_FLOAT: 'ALWAYS_LE_TFLOAT_FLOAT' | 'always_le_tfloat_float'; +ALWAYS_LT_TFLOAT_FLOAT: 'ALWAYS_LT_TFLOAT_FLOAT' | 'always_lt_tfloat_float'; +ALWAYS_NE_TFLOAT_FLOAT: 'ALWAYS_NE_TFLOAT_FLOAT' | 'always_ne_tfloat_float'; EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; EVER_EQ_TFLOAT_FLOAT: 'EVER_EQ_TFLOAT_FLOAT' | 'ever_eq_tfloat_float'; EVER_GE_TFLOAT_FLOAT: 'EVER_GE_TFLOAT_FLOAT' | 'ever_ge_tfloat_float'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 545ac88c27..40fe84a909 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -133,6 +133,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -3094,6 +3100,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: EVER_NE_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ + case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GE_TFLOAT_FLOAT */ + case AntlrSQLLexer::ALWAYS_GE_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GE_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGeTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GE_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GT_TFLOAT_FLOAT */ + case AntlrSQLLexer::ALWAYS_GT_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GT_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGtTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GT_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LE_TFLOAT_FLOAT */ + case AntlrSQLLexer::ALWAYS_LE_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LE_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLeTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LE_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LT_TFLOAT_FLOAT */ + case AntlrSQLLexer::ALWAYS_LT_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LT_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLtTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LT_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_TFLOAT_FLOAT */ + case AntlrSQLLexer::ALWAYS_NE_TFLOAT_FLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_NE_TFLOAT_FLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysNeTfloatFloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TFLOAT_FLOAT */ default: /// Check if the function is a constructor for a datatype From d5446af260c5c3ae8ba0f8c39be4e255fd6c8088 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 08:55:56 +0200 Subject: [PATCH 21/86] feat(meos): add EVER_EQ/GE/GT/LE/LT/NE_TINT_INT NES operators (W63) Adds six per-event ever-comparison scalar operators for tint against an int threshold: EVER_EQ_TINT_INT, EVER_GE_TINT_INT, EVER_GT_TINT_INT, EVER_LE_TINT_INT, EVER_LT_TINT_INT, EVER_NE_TINT_INT. Each operator constructs a single-instant tint from (value, ts), calls the corresponding MEOS ever_*_tint_int kernel returning int, and emits the result as double. Logical and physical function pairs, CMakeLists plugin registrations, AntlrSQL grammar tokens, and AntlrSQLQueryPlanCreator case blocks are included. --- .../Meos/EverEqTintIntLogicalFunction.hpp | 54 ++++++ .../Meos/EverGeTintIntLogicalFunction.hpp | 54 ++++++ .../Meos/EverGtTintIntLogicalFunction.hpp | 54 ++++++ .../Meos/EverLeTintIntLogicalFunction.hpp | 54 ++++++ .../Meos/EverLtTintIntLogicalFunction.hpp | 54 ++++++ .../Meos/EverNeTintIntLogicalFunction.hpp | 54 ++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../Meos/EverEqTintIntLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverGeTintIntLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverGtTintIntLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverLeTintIntLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverLtTintIntLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverNeTintIntLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverEqTintIntPhysicalFunction.hpp | 43 +++++ .../Meos/EverGeTintIntPhysicalFunction.hpp | 43 +++++ .../Meos/EverGtTintIntPhysicalFunction.hpp | 43 +++++ .../Meos/EverLeTintIntPhysicalFunction.hpp | 43 +++++ .../Meos/EverLtTintIntPhysicalFunction.hpp | 43 +++++ .../Meos/EverNeTintIntPhysicalFunction.hpp | 43 +++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../Meos/EverEqTintIntPhysicalFunction.cpp | 88 +++++++++ .../Meos/EverGeTintIntPhysicalFunction.cpp | 88 +++++++++ .../Meos/EverGtTintIntPhysicalFunction.cpp | 88 +++++++++ .../Meos/EverLeTintIntPhysicalFunction.cpp | 88 +++++++++ .../Meos/EverLtTintIntPhysicalFunction.cpp | 88 +++++++++ .../Meos/EverNeTintIntPhysicalFunction.cpp | 88 +++++++++ nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 180 ++++++++++++++++++ 28 files changed, 1939 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGeTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGtTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLeTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLtTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGeTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGtTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLeTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLtTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTintIntLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGeTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGtTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLeTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLtTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGeTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGtTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLeTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLtTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTintIntPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..e744c59456 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_eq_tint_int: tests if a single-instant tint value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_eq_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverEqTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTintInt"; + + EverEqTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGeTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..7412b45a33 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGeTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ge_tint_int: tests if a single-instant tint value ever is >= a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ge_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGeTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGeTintInt"; + + EverGeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGtTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..d23b02d567 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGtTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_gt_tint_int: tests if a single-instant tint value ever is > a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_gt_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGtTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGtTintInt"; + + EverGtTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLeTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..a8e893d848 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLeTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_le_tint_int: tests if a single-instant tint value ever is <= a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_le_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLeTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLeTintInt"; + + EverLeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLtTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..081cc445a5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLtTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_lt_tint_int: tests if a single-instant tint value ever is < a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_lt_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLtTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLtTintInt"; + + EverLtTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..92c335e27b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ne_tint_int: tests if a single-instant tint value ever is != a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ne_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverNeTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTintInt"; + + EverNeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index f80fb56ab9..be5e7a0bc2 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -88,3 +88,9 @@ add_plugin(AlwaysGtTfloatFloat LogicalFunction nes-logical-operators AlwaysGtTfl add_plugin(AlwaysLeTfloatFloat LogicalFunction nes-logical-operators AlwaysLeTfloatFloatLogicalFunction.cpp) add_plugin(AlwaysLtTfloatFloat LogicalFunction nes-logical-operators AlwaysLtTfloatFloatLogicalFunction.cpp) add_plugin(AlwaysNeTfloatFloat LogicalFunction nes-logical-operators AlwaysNeTfloatFloatLogicalFunction.cpp) +add_plugin(EverEqTintInt LogicalFunction nes-logical-operators EverEqTintIntLogicalFunction.cpp) +add_plugin(EverGeTintInt LogicalFunction nes-logical-operators EverGeTintIntLogicalFunction.cpp) +add_plugin(EverGtTintInt LogicalFunction nes-logical-operators EverGtTintIntLogicalFunction.cpp) +add_plugin(EverLeTintInt LogicalFunction nes-logical-operators EverLeTintIntLogicalFunction.cpp) +add_plugin(EverLtTintInt LogicalFunction nes-logical-operators EverLtTintIntLogicalFunction.cpp) +add_plugin(EverNeTintInt LogicalFunction nes-logical-operators EverNeTintIntLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..1bbb6b868e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTintIntLogicalFunction::EverEqTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverEqTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTintIntLogicalFunction::getType() const { return NAME; } + +bool EverEqTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverEqTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverEqTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverEqTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..16960ea72f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGeTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGeTintIntLogicalFunction::EverGeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGeTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGeTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGeTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGeTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGeTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGeTintIntLogicalFunction::getType() const { return NAME; } + +bool EverGeTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGeTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGeTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGeTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGeTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGeTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..5b91ec4001 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGtTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGtTintIntLogicalFunction::EverGtTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGtTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGtTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGtTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGtTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGtTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGtTintIntLogicalFunction::getType() const { return NAME; } + +bool EverGtTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGtTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGtTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGtTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGtTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGtTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..3ea5fc988d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLeTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLeTintIntLogicalFunction::EverLeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLeTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLeTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLeTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLeTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLeTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLeTintIntLogicalFunction::getType() const { return NAME; } + +bool EverLeTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLeTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLeTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLeTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLeTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLeTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..86d0846523 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLtTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLtTintIntLogicalFunction::EverLtTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLtTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLtTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLtTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLtTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLtTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLtTintIntLogicalFunction::getType() const { return NAME; } + +bool EverLtTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLtTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLtTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLtTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLtTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLtTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..a734230251 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTintIntLogicalFunction::EverNeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverNeTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTintIntLogicalFunction::getType() const { return NAME; } + +bool EverNeTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverNeTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverNeTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverNeTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..733617927d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_eq_tint_int`. + * + * Per-event ever_eq_tint_int: tests if a single-instant tint value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverEqTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGeTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..1dc5cec153 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGeTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ge_tint_int`. + * + * Per-event ever_ge_tint_int: tests if a single-instant tint value ever is >= a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGeTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGtTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..0f9b5870f8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGtTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_gt_tint_int`. + * + * Per-event ever_gt_tint_int: tests if a single-instant tint value ever is > a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGtTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGtTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLeTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..1754b67658 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLeTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_le_tint_int`. + * + * Per-event ever_le_tint_int: tests if a single-instant tint value ever is <= a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLeTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLtTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..5631102874 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLtTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_lt_tint_int`. + * + * Per-event ever_lt_tint_int: tests if a single-instant tint value ever is < a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLtTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLtTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..f6473e9e59 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ne_tint_int`. + * + * Per-event ever_ne_tint_int: tests if a single-instant tint value ever is != a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverNeTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 1cf15e45be..420c67c1c7 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -87,4 +87,10 @@ add_plugin(AlwaysGtTfloatFloat PhysicalFunction nes-physical-operators AlwaysGtT add_plugin(AlwaysLeTfloatFloat PhysicalFunction nes-physical-operators AlwaysLeTfloatFloatPhysicalFunction.cpp) add_plugin(AlwaysLtTfloatFloat PhysicalFunction nes-physical-operators AlwaysLtTfloatFloatPhysicalFunction.cpp) add_plugin(AlwaysNeTfloatFloat PhysicalFunction nes-physical-operators AlwaysNeTfloatFloatPhysicalFunction.cpp) +add_plugin(EverEqTintInt PhysicalFunction nes-physical-operators EverEqTintIntPhysicalFunction.cpp) +add_plugin(EverGeTintInt PhysicalFunction nes-physical-operators EverGeTintIntPhysicalFunction.cpp) +add_plugin(EverGtTintInt PhysicalFunction nes-physical-operators EverGtTintIntPhysicalFunction.cpp) +add_plugin(EverLeTintInt PhysicalFunction nes-physical-operators EverLeTintIntPhysicalFunction.cpp) +add_plugin(EverLtTintInt PhysicalFunction nes-physical-operators EverLtTintIntPhysicalFunction.cpp) +add_plugin(EverNeTintInt PhysicalFunction nes-physical-operators EverNeTintIntPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..15d58a4f09 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTintIntPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTintIntPhysicalFunction::EverEqTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverEqTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_eq_tint_int(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverEqTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGeTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..582a28b16f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGeTintIntPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGeTintIntPhysicalFunction::EverGeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGeTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_ge_tint_int(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGeTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGeTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGeTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGtTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..4c9a2188cc --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGtTintIntPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGtTintIntPhysicalFunction::EverGtTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGtTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_gt_tint_int(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGtTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGtTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGtTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLeTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..76a79ac980 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLeTintIntPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLeTintIntPhysicalFunction::EverLeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLeTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_le_tint_int(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLeTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLeTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLeTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLtTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..d44fcd56b5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLtTintIntPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLtTintIntPhysicalFunction::EverLtTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLtTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_lt_tint_int(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLtTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLtTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLtTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..01efb51d81 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTintIntPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTintIntPhysicalFunction::EverNeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverNeTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_ne_tint_int(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverNeTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 28cd19856c..0397f7cc02 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | EDWITHIN_TGEO_GEO | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | EDWITHIN_TGEO_GEO | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -499,6 +499,12 @@ EVER_GT_TFLOAT_FLOAT: 'EVER_GT_TFLOAT_FLOAT' | 'ever_gt_tfloat_float'; EVER_LE_TFLOAT_FLOAT: 'EVER_LE_TFLOAT_FLOAT' | 'ever_le_tfloat_float'; EVER_LT_TFLOAT_FLOAT: 'EVER_LT_TFLOAT_FLOAT' | 'ever_lt_tfloat_float'; EVER_NE_TFLOAT_FLOAT: 'EVER_NE_TFLOAT_FLOAT' | 'ever_ne_tfloat_float'; +EVER_EQ_TINT_INT: 'EVER_EQ_TINT_INT' | 'ever_eq_tint_int'; +EVER_GE_TINT_INT: 'EVER_GE_TINT_INT' | 'ever_ge_tint_int'; +EVER_GT_TINT_INT: 'EVER_GT_TINT_INT' | 'ever_gt_tint_int'; +EVER_LE_TINT_INT: 'EVER_LE_TINT_INT' | 'ever_le_tint_int'; +EVER_LT_TINT_INT: 'EVER_LT_TINT_INT' | 'ever_lt_tint_int'; +EVER_NE_TINT_INT: 'EVER_NE_TINT_INT' | 'ever_ne_tint_int'; TGEO_AT_STBOX: 'TGEO_AT_STBOX' | 'tgeo_at_stbox'; ADD_BIGINT_TBIGINT: 'ADD_BIGINT_TBIGINT' | 'add_bigint_tbigint'; ADD_FLOAT_TFLOAT: 'ADD_FLOAT_TFLOAT' | 'add_float_tfloat'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 40fe84a909..a95b1e1ad1 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -133,6 +133,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -3100,6 +3106,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: EVER_NE_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TINT_INT */ + case AntlrSQLLexer::EVER_EQ_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GE_TINT_INT */ + case AntlrSQLLexer::EVER_GE_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GE_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGeTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GE_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GT_TINT_INT */ + case AntlrSQLLexer::EVER_GT_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GT_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGtTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GT_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LE_TINT_INT */ + case AntlrSQLLexer::EVER_LE_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LE_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLeTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LE_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LT_TINT_INT */ + case AntlrSQLLexer::EVER_LT_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LT_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLtTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LT_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_TINT_INT */ + case AntlrSQLLexer::EVER_NE_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_NE_TINT_INT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 0dc2fef5f3db052a594ab7a5446c53d116a15fe1 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 09:01:58 +0200 Subject: [PATCH 22/86] feat(meos): add ALWAYS_EQ/GE/GT/LE/LT/NE_TINT_INT NES operators (W64) Adds six per-event always-comparison scalar operators for tint against an int threshold: ALWAYS_EQ_TINT_INT, ALWAYS_GE_TINT_INT, ALWAYS_GT_TINT_INT, ALWAYS_LE_TINT_INT, ALWAYS_LT_TINT_INT, ALWAYS_NE_TINT_INT. Each operator constructs a single-instant tint from (value, ts), calls the corresponding MEOS always_*_tint_int kernel returning int, and emits the result as double. Logical and physical function pairs, CMakeLists plugin registrations, AntlrSQL grammar tokens, and AntlrSQLQueryPlanCreator case blocks are included. --- .../Meos/AlwaysEqTintIntLogicalFunction.hpp | 54 ++++++ .../Meos/AlwaysGeTintIntLogicalFunction.hpp | 54 ++++++ .../Meos/AlwaysGtTintIntLogicalFunction.hpp | 54 ++++++ .../Meos/AlwaysLeTintIntLogicalFunction.hpp | 54 ++++++ .../Meos/AlwaysLtTintIntLogicalFunction.hpp | 54 ++++++ .../Meos/AlwaysNeTintIntLogicalFunction.hpp | 54 ++++++ .../Meos/AlwaysEqTintIntLogicalFunction.cpp | 105 ++++++++++ .../Meos/AlwaysGeTintIntLogicalFunction.cpp | 105 ++++++++++ .../Meos/AlwaysGtTintIntLogicalFunction.cpp | 105 ++++++++++ .../Meos/AlwaysLeTintIntLogicalFunction.cpp | 105 ++++++++++ .../Meos/AlwaysLtTintIntLogicalFunction.cpp | 105 ++++++++++ .../Meos/AlwaysNeTintIntLogicalFunction.cpp | 105 ++++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../Meos/AlwaysEqTintIntPhysicalFunction.hpp | 43 +++++ .../Meos/AlwaysGeTintIntPhysicalFunction.hpp | 43 +++++ .../Meos/AlwaysGtTintIntPhysicalFunction.hpp | 43 +++++ .../Meos/AlwaysLeTintIntPhysicalFunction.hpp | 43 +++++ .../Meos/AlwaysLtTintIntPhysicalFunction.hpp | 43 +++++ .../Meos/AlwaysNeTintIntPhysicalFunction.hpp | 43 +++++ .../Meos/AlwaysEqTintIntPhysicalFunction.cpp | 88 +++++++++ .../Meos/AlwaysGeTintIntPhysicalFunction.cpp | 88 +++++++++ .../Meos/AlwaysGtTintIntPhysicalFunction.cpp | 88 +++++++++ .../Meos/AlwaysLeTintIntPhysicalFunction.cpp | 88 +++++++++ .../Meos/AlwaysLtTintIntPhysicalFunction.cpp | 88 +++++++++ .../Meos/AlwaysNeTintIntPhysicalFunction.cpp | 88 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 180 ++++++++++++++++++ 28 files changed, 1939 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGeTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGtTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLeTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLtTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGeTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGtTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLeTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLtTintIntLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTintIntLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGeTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGtTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLeTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLtTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGeTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGtTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLeTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLtTintIntPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTintIntPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..81cadb7f63 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_eq_tint_int: tests if a single-instant tint value always equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_eq_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysEqTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTintInt"; + + AlwaysEqTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..2a6fb630b5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ge_tint_int: tests if a single-instant tint value always is greater than or equal to a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ge_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGeTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGeTintInt"; + + AlwaysGeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..cb8089aa89 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_gt_tint_int: tests if a single-instant tint value always is greater than a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_gt_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGtTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGtTintInt"; + + AlwaysGtTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..10bde702b8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_le_tint_int: tests if a single-instant tint value always is less than or equal to a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_le_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLeTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLeTintInt"; + + AlwaysLeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..260aa2d34d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_lt_tint_int: tests if a single-instant tint value always is less than a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_lt_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLtTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLtTintInt"; + + AlwaysLtTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..ab97eaf8c4 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ne_tint_int: tests if a single-instant tint value always does not equal a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ne_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysNeTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTintInt"; + + AlwaysNeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..25a4b5176e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTintIntLogicalFunction::AlwaysEqTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysEqTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTintIntLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysEqTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysEqTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysEqTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..98a51fe375 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGeTintIntLogicalFunction::AlwaysGeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGeTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGeTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGeTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGeTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGeTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGeTintIntLogicalFunction::getType() const { return NAME; } + +bool AlwaysGeTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGeTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGeTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGeTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGeTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGeTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..7060f1d054 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGtTintIntLogicalFunction::AlwaysGtTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGtTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGtTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGtTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGtTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGtTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGtTintIntLogicalFunction::getType() const { return NAME; } + +bool AlwaysGtTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGtTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGtTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGtTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGtTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGtTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..6ce9d79efb --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLeTintIntLogicalFunction::AlwaysLeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLeTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLeTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLeTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLeTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLeTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLeTintIntLogicalFunction::getType() const { return NAME; } + +bool AlwaysLeTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLeTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLeTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLeTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLeTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLeTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..20fcc7fb98 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLtTintIntLogicalFunction::AlwaysLtTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLtTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLtTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLtTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLtTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLtTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLtTintIntLogicalFunction::getType() const { return NAME; } + +bool AlwaysLtTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLtTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLtTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLtTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLtTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLtTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..b9f82b9867 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTintIntLogicalFunction::AlwaysNeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysNeTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTintIntLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysNeTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysNeTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysNeTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index be5e7a0bc2..18adc03f99 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -94,3 +94,9 @@ add_plugin(EverGtTintInt LogicalFunction nes-logical-operators EverGtTintIntLogi add_plugin(EverLeTintInt LogicalFunction nes-logical-operators EverLeTintIntLogicalFunction.cpp) add_plugin(EverLtTintInt LogicalFunction nes-logical-operators EverLtTintIntLogicalFunction.cpp) add_plugin(EverNeTintInt LogicalFunction nes-logical-operators EverNeTintIntLogicalFunction.cpp) +add_plugin(AlwaysEqTintInt LogicalFunction nes-logical-operators AlwaysEqTintIntLogicalFunction.cpp) +add_plugin(AlwaysGeTintInt LogicalFunction nes-logical-operators AlwaysGeTintIntLogicalFunction.cpp) +add_plugin(AlwaysGtTintInt LogicalFunction nes-logical-operators AlwaysGtTintIntLogicalFunction.cpp) +add_plugin(AlwaysLeTintInt LogicalFunction nes-logical-operators AlwaysLeTintIntLogicalFunction.cpp) +add_plugin(AlwaysLtTintInt LogicalFunction nes-logical-operators AlwaysLtTintIntLogicalFunction.cpp) +add_plugin(AlwaysNeTintInt LogicalFunction nes-logical-operators AlwaysNeTintIntLogicalFunction.cpp) diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..bd447a115a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_eq_tint_int`. + * + * Per-event always_eq_tint_int: tests if a single-instant tint value always equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysEqTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..ab84836820 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ge_tint_int`. + * + * Per-event always_ge_tint_int: tests if a single-instant tint value always is greater than or equal to a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGeTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..f8d58ce187 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_gt_tint_int`. + * + * Per-event always_gt_tint_int: tests if a single-instant tint value always is greater than a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGtTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGtTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..5fcc072903 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_le_tint_int`. + * + * Per-event always_le_tint_int: tests if a single-instant tint value always is less than or equal to a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLeTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..bfaa3c74ad --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_lt_tint_int`. + * + * Per-event always_lt_tint_int: tests if a single-instant tint value always is less than a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLtTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLtTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..da81199476 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ne_tint_int`. + * + * Per-event always_ne_tint_int: tests if a single-instant tint value always does not equal a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysNeTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..acf460907c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTintIntPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTintIntPhysicalFunction::AlwaysEqTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_eq_tint_int(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysEqTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..10b57b46b0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeTintIntPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGeTintIntPhysicalFunction::AlwaysGeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGeTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_ge_tint_int(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGeTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGeTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGeTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..9000b7a404 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtTintIntPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGtTintIntPhysicalFunction::AlwaysGtTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGtTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_gt_tint_int(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGtTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGtTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGtTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..2bc48852c9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeTintIntPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLeTintIntPhysicalFunction::AlwaysLeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLeTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_le_tint_int(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLeTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLeTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLeTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..f4a3efe5b0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtTintIntPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLtTintIntPhysicalFunction::AlwaysLtTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLtTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_lt_tint_int(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLtTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLtTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLtTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..0d7634b12d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTintIntPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTintIntPhysicalFunction::AlwaysNeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_ne_tint_int(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysNeTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 420c67c1c7..c31c9c6034 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -93,4 +93,10 @@ add_plugin(EverGtTintInt PhysicalFunction nes-physical-operators EverGtTintIntPh add_plugin(EverLeTintInt PhysicalFunction nes-physical-operators EverLeTintIntPhysicalFunction.cpp) add_plugin(EverLtTintInt PhysicalFunction nes-physical-operators EverLtTintIntPhysicalFunction.cpp) add_plugin(EverNeTintInt PhysicalFunction nes-physical-operators EverNeTintIntPhysicalFunction.cpp) +add_plugin(AlwaysEqTintInt PhysicalFunction nes-physical-operators AlwaysEqTintIntPhysicalFunction.cpp) +add_plugin(AlwaysGeTintInt PhysicalFunction nes-physical-operators AlwaysGeTintIntPhysicalFunction.cpp) +add_plugin(AlwaysGtTintInt PhysicalFunction nes-physical-operators AlwaysGtTintIntPhysicalFunction.cpp) +add_plugin(AlwaysLeTintInt PhysicalFunction nes-physical-operators AlwaysLeTintIntPhysicalFunction.cpp) +add_plugin(AlwaysLtTintInt PhysicalFunction nes-physical-operators AlwaysLtTintIntPhysicalFunction.cpp) +add_plugin(AlwaysNeTintInt PhysicalFunction nes-physical-operators AlwaysNeTintIntPhysicalFunction.cpp) endif() diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 0397f7cc02..4dfe041161 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | EDWITHIN_TGEO_GEO | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | EDWITHIN_TGEO_GEO | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -492,6 +492,12 @@ ALWAYS_GT_TFLOAT_FLOAT: 'ALWAYS_GT_TFLOAT_FLOAT' | 'always_gt_tfloat_float'; ALWAYS_LE_TFLOAT_FLOAT: 'ALWAYS_LE_TFLOAT_FLOAT' | 'always_le_tfloat_float'; ALWAYS_LT_TFLOAT_FLOAT: 'ALWAYS_LT_TFLOAT_FLOAT' | 'always_lt_tfloat_float'; ALWAYS_NE_TFLOAT_FLOAT: 'ALWAYS_NE_TFLOAT_FLOAT' | 'always_ne_tfloat_float'; +ALWAYS_EQ_TINT_INT: 'ALWAYS_EQ_TINT_INT' | 'always_eq_tint_int'; +ALWAYS_GE_TINT_INT: 'ALWAYS_GE_TINT_INT' | 'always_ge_tint_int'; +ALWAYS_GT_TINT_INT: 'ALWAYS_GT_TINT_INT' | 'always_gt_tint_int'; +ALWAYS_LE_TINT_INT: 'ALWAYS_LE_TINT_INT' | 'always_le_tint_int'; +ALWAYS_LT_TINT_INT: 'ALWAYS_LT_TINT_INT' | 'always_lt_tint_int'; +ALWAYS_NE_TINT_INT: 'ALWAYS_NE_TINT_INT' | 'always_ne_tint_int'; EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; EVER_EQ_TFLOAT_FLOAT: 'EVER_EQ_TFLOAT_FLOAT' | 'ever_eq_tfloat_float'; EVER_GE_TFLOAT_FLOAT: 'EVER_GE_TFLOAT_FLOAT' | 'ever_ge_tfloat_float'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index a95b1e1ad1..12eec3b344 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -133,6 +133,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -3280,6 +3286,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: EVER_NE_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TINT_INT */ + case AntlrSQLLexer::ALWAYS_EQ_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GE_TINT_INT */ + case AntlrSQLLexer::ALWAYS_GE_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GE_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGeTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GE_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GT_TINT_INT */ + case AntlrSQLLexer::ALWAYS_GT_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GT_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGtTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GT_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LE_TINT_INT */ + case AntlrSQLLexer::ALWAYS_LE_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LE_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLeTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LE_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LT_TINT_INT */ + case AntlrSQLLexer::ALWAYS_LT_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LT_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLtTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LT_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_TINT_INT */ + case AntlrSQLLexer::ALWAYS_NE_TINT_INT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_NE_TINT_INT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysNeTintIntLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TINT_INT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 346aed152c314d6b1ad449c3e6ec6a43fb30472f Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 09:05:08 +0200 Subject: [PATCH 23/86] feat(meos): add EVER_EQ/GE/GT/LE/LT/NE_TBIGINT_BIGINT NES operators (W65) Adds six per-event ever-comparison scalar operators for tbigint against a bigint threshold: EVER_EQ_TBIGINT_BIGINT, EVER_GE_TBIGINT_BIGINT, EVER_GT_TBIGINT_BIGINT, EVER_LE_TBIGINT_BIGINT, EVER_LT_TBIGINT_BIGINT, EVER_NE_TBIGINT_BIGINT. Each operator constructs a single-instant tbigint from (value, ts), calls the corresponding MEOS ever_*_tbigint_bigint kernel returning int, and emits the result as double. Logical and physical function pairs, CMakeLists plugin registrations, AntlrSQL grammar tokens, and AntlrSQLQueryPlanCreator case blocks are included. --- .../EverEqTbigintBigintLogicalFunction.hpp | 54 ++++++ .../EverGeTbigintBigintLogicalFunction.hpp | 54 ++++++ .../EverGtTbigintBigintLogicalFunction.hpp | 54 ++++++ .../EverLeTbigintBigintLogicalFunction.hpp | 54 ++++++ .../EverLtTbigintBigintLogicalFunction.hpp | 54 ++++++ .../EverNeTbigintBigintLogicalFunction.hpp | 54 ++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../EverEqTbigintBigintLogicalFunction.cpp | 105 ++++++++++ .../EverGeTbigintBigintLogicalFunction.cpp | 105 ++++++++++ .../EverGtTbigintBigintLogicalFunction.cpp | 105 ++++++++++ .../EverLeTbigintBigintLogicalFunction.cpp | 105 ++++++++++ .../EverLtTbigintBigintLogicalFunction.cpp | 105 ++++++++++ .../EverNeTbigintBigintLogicalFunction.cpp | 105 ++++++++++ .../EverEqTbigintBigintPhysicalFunction.hpp | 43 +++++ .../EverGeTbigintBigintPhysicalFunction.hpp | 43 +++++ .../EverGtTbigintBigintPhysicalFunction.hpp | 43 +++++ .../EverLeTbigintBigintPhysicalFunction.hpp | 43 +++++ .../EverLtTbigintBigintPhysicalFunction.hpp | 43 +++++ .../EverNeTbigintBigintPhysicalFunction.hpp | 43 +++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../EverEqTbigintBigintPhysicalFunction.cpp | 88 +++++++++ .../EverGeTbigintBigintPhysicalFunction.cpp | 88 +++++++++ .../EverGtTbigintBigintPhysicalFunction.cpp | 88 +++++++++ .../EverLeTbigintBigintPhysicalFunction.cpp | 88 +++++++++ .../EverLtTbigintBigintPhysicalFunction.cpp | 88 +++++++++ .../EverNeTbigintBigintPhysicalFunction.cpp | 88 +++++++++ nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 180 ++++++++++++++++++ 28 files changed, 1939 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGeTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGtTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLeTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLtTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTbigintBigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGeTbigintBigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGtTbigintBigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLeTbigintBigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLtTbigintBigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTbigintBigintLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGeTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGtTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLeTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLtTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTbigintBigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGeTbigintBigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGtTbigintBigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLeTbigintBigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLtTbigintBigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTbigintBigintPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..53667c623c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_eq_tbigint_bigint: tests if a single-instant tbigint value ever eqs a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_eq_tbigint_bigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverEqTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTbigintBigint"; + + EverEqTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGeTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..fb283efa26 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGeTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ge_tbigint_bigint: tests if a single-instant tbigint value ever ges a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ge_tbigint_bigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGeTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGeTbigintBigint"; + + EverGeTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGtTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..80fa5cf7e0 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGtTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_gt_tbigint_bigint: tests if a single-instant tbigint value ever gts a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_gt_tbigint_bigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGtTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGtTbigintBigint"; + + EverGtTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLeTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..e85cf1183b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLeTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_le_tbigint_bigint: tests if a single-instant tbigint value ever les a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_le_tbigint_bigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLeTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLeTbigintBigint"; + + EverLeTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLtTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..91456fee24 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLtTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_lt_tbigint_bigint: tests if a single-instant tbigint value ever lts a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_lt_tbigint_bigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLtTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLtTbigintBigint"; + + EverLtTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..5e78502677 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ne_tbigint_bigint: tests if a single-instant tbigint value ever nes a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ne_tbigint_bigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverNeTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTbigintBigint"; + + EverNeTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 18adc03f99..27a547c802 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -100,3 +100,9 @@ add_plugin(AlwaysGtTintInt LogicalFunction nes-logical-operators AlwaysGtTintInt add_plugin(AlwaysLeTintInt LogicalFunction nes-logical-operators AlwaysLeTintIntLogicalFunction.cpp) add_plugin(AlwaysLtTintInt LogicalFunction nes-logical-operators AlwaysLtTintIntLogicalFunction.cpp) add_plugin(AlwaysNeTintInt LogicalFunction nes-logical-operators AlwaysNeTintIntLogicalFunction.cpp) +add_plugin(EverEqTbigintBigint LogicalFunction nes-logical-operators EverEqTbigintBigintLogicalFunction.cpp) +add_plugin(EverGeTbigintBigint LogicalFunction nes-logical-operators EverGeTbigintBigintLogicalFunction.cpp) +add_plugin(EverGtTbigintBigint LogicalFunction nes-logical-operators EverGtTbigintBigintLogicalFunction.cpp) +add_plugin(EverLeTbigintBigint LogicalFunction nes-logical-operators EverLeTbigintBigintLogicalFunction.cpp) +add_plugin(EverLtTbigintBigint LogicalFunction nes-logical-operators EverLtTbigintBigintLogicalFunction.cpp) +add_plugin(EverNeTbigintBigint LogicalFunction nes-logical-operators EverNeTbigintBigintLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..63cb64adc8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTbigintBigintLogicalFunction::EverEqTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverEqTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool EverEqTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverEqTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverEqTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverEqTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..b1d661e0b8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGeTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGeTbigintBigintLogicalFunction::EverGeTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGeTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGeTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGeTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGeTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGeTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGeTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool EverGeTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGeTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGeTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGeTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGeTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGeTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..f8689bed1f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGtTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGtTbigintBigintLogicalFunction::EverGtTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGtTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGtTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGtTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGtTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGtTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGtTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool EverGtTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGtTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGtTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGtTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGtTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGtTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..24d09cd35e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLeTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLeTbigintBigintLogicalFunction::EverLeTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLeTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLeTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLeTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLeTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLeTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLeTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool EverLeTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLeTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLeTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLeTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLeTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLeTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..010345f59c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLtTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLtTbigintBigintLogicalFunction::EverLtTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLtTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLtTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLtTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLtTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLtTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLtTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool EverLtTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLtTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLtTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLtTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLtTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLtTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..1c385ff7af --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTbigintBigintLogicalFunction::EverNeTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverNeTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool EverNeTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverNeTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverNeTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverNeTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..0d9dd4195f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_eq_tbigint_bigint`. + * + * Per-event ever_eq_tbigint_bigint: tests if a single-instant tbigint value ever eqs a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverEqTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGeTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..390aee0c48 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGeTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ge_tbigint_bigint`. + * + * Per-event ever_ge_tbigint_bigint: tests if a single-instant tbigint value ever ges a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGeTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGeTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGtTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..a13411d83f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGtTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_gt_tbigint_bigint`. + * + * Per-event ever_gt_tbigint_bigint: tests if a single-instant tbigint value ever gts a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGtTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGtTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLeTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..8e99ab050c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLeTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_le_tbigint_bigint`. + * + * Per-event ever_le_tbigint_bigint: tests if a single-instant tbigint value ever les a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLeTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLeTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLtTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..cbb8e2338b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLtTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_lt_tbigint_bigint`. + * + * Per-event ever_lt_tbigint_bigint: tests if a single-instant tbigint value ever lts a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLtTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLtTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..54ff0c5f7b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ne_tbigint_bigint`. + * + * Per-event ever_ne_tbigint_bigint: tests if a single-instant tbigint value ever nes a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverNeTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index c31c9c6034..340d0c6aaa 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -99,4 +99,10 @@ add_plugin(AlwaysGtTintInt PhysicalFunction nes-physical-operators AlwaysGtTintI add_plugin(AlwaysLeTintInt PhysicalFunction nes-physical-operators AlwaysLeTintIntPhysicalFunction.cpp) add_plugin(AlwaysLtTintInt PhysicalFunction nes-physical-operators AlwaysLtTintIntPhysicalFunction.cpp) add_plugin(AlwaysNeTintInt PhysicalFunction nes-physical-operators AlwaysNeTintIntPhysicalFunction.cpp) +add_plugin(EverEqTbigintBigint PhysicalFunction nes-physical-operators EverEqTbigintBigintPhysicalFunction.cpp) +add_plugin(EverGeTbigintBigint PhysicalFunction nes-physical-operators EverGeTbigintBigintPhysicalFunction.cpp) +add_plugin(EverGtTbigintBigint PhysicalFunction nes-physical-operators EverGtTbigintBigintPhysicalFunction.cpp) +add_plugin(EverLeTbigintBigint PhysicalFunction nes-physical-operators EverLeTbigintBigintPhysicalFunction.cpp) +add_plugin(EverLtTbigintBigint PhysicalFunction nes-physical-operators EverLtTbigintBigintPhysicalFunction.cpp) +add_plugin(EverNeTbigintBigint PhysicalFunction nes-physical-operators EverNeTbigintBigintPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..bbbda8e3b1 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTbigintBigintPhysicalFunction::EverEqTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverEqTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_eq_tbigint_bigint(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverEqTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGeTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..66e760ca67 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGeTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGeTbigintBigintPhysicalFunction::EverGeTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGeTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_ge_tbigint_bigint(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGeTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGeTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGeTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGtTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..fc74e3aef9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGtTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGtTbigintBigintPhysicalFunction::EverGtTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGtTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_gt_tbigint_bigint(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGtTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGtTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGtTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLeTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..b1b012d279 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLeTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLeTbigintBigintPhysicalFunction::EverLeTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLeTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_le_tbigint_bigint(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLeTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLeTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLeTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLtTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..d28da880aa --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLtTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLtTbigintBigintPhysicalFunction::EverLtTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLtTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_lt_tbigint_bigint(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLtTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLtTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLtTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..b102a2901b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTbigintBigintPhysicalFunction::EverNeTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverNeTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = ever_ne_tbigint_bigint(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverNeTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 4dfe041161..8866198a2d 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | EDWITHIN_TGEO_GEO | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -499,6 +499,12 @@ ALWAYS_LE_TINT_INT: 'ALWAYS_LE_TINT_INT' | 'always_le_tint_int'; ALWAYS_LT_TINT_INT: 'ALWAYS_LT_TINT_INT' | 'always_lt_tint_int'; ALWAYS_NE_TINT_INT: 'ALWAYS_NE_TINT_INT' | 'always_ne_tint_int'; EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; +EVER_EQ_TBIGINT_BIGINT: 'EVER_EQ_TBIGINT_BIGINT' | 'ever_eq_tbigint_bigint'; +EVER_GE_TBIGINT_BIGINT: 'EVER_GE_TBIGINT_BIGINT' | 'ever_ge_tbigint_bigint'; +EVER_GT_TBIGINT_BIGINT: 'EVER_GT_TBIGINT_BIGINT' | 'ever_gt_tbigint_bigint'; +EVER_LE_TBIGINT_BIGINT: 'EVER_LE_TBIGINT_BIGINT' | 'ever_le_tbigint_bigint'; +EVER_LT_TBIGINT_BIGINT: 'EVER_LT_TBIGINT_BIGINT' | 'ever_lt_tbigint_bigint'; +EVER_NE_TBIGINT_BIGINT: 'EVER_NE_TBIGINT_BIGINT' | 'ever_ne_tbigint_bigint'; EVER_EQ_TFLOAT_FLOAT: 'EVER_EQ_TFLOAT_FLOAT' | 'ever_eq_tfloat_float'; EVER_GE_TFLOAT_FLOAT: 'EVER_GE_TFLOAT_FLOAT' | 'ever_ge_tfloat_float'; EVER_GT_TFLOAT_FLOAT: 'EVER_GT_TFLOAT_FLOAT' | 'ever_gt_tfloat_float'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 12eec3b344..f1b94976e1 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -133,6 +133,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -2938,6 +2944,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TINT_TO_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TBIGINT_BIGINT */ + case AntlrSQLLexer::EVER_EQ_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GE_TBIGINT_BIGINT */ + case AntlrSQLLexer::EVER_GE_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GE_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGeTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GE_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GT_TBIGINT_BIGINT */ + case AntlrSQLLexer::EVER_GT_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GT_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGtTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GT_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LE_TBIGINT_BIGINT */ + case AntlrSQLLexer::EVER_LE_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LE_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLeTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LE_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LT_TBIGINT_BIGINT */ + case AntlrSQLLexer::EVER_LT_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LT_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLtTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LT_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_TBIGINT_BIGINT */ + case AntlrSQLLexer::EVER_NE_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_NE_TBIGINT_BIGINT */ /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::EVER_EQ_TFLOAT_FLOAT: { From d8510a7a4553ffb3c9d4d5103c167592df432595 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 09:10:25 +0200 Subject: [PATCH 24/86] feat(meos): add ALWAYS_EQ/GE/GT/LE/LT/NE_TBIGINT_BIGINT NES operators (W66) Adds six per-event always-comparison scalar operators for tbigint against a bigint threshold: ALWAYS_EQ_TBIGINT_BIGINT, ALWAYS_GE_TBIGINT_BIGINT, ALWAYS_GT_TBIGINT_BIGINT, ALWAYS_LE_TBIGINT_BIGINT, ALWAYS_LT_TBIGINT_BIGINT, ALWAYS_NE_TBIGINT_BIGINT. Each operator constructs a single-instant tbigint from (value, ts), calls the corresponding MEOS always_*_tbigint_bigint kernel returning int, and emits the result as double. Logical and physical function pairs, CMakeLists plugin registrations, AntlrSQL grammar tokens, and AntlrSQLQueryPlanCreator case blocks are included. --- .../AlwaysEqTbigintBigintLogicalFunction.hpp | 54 ++++++ .../AlwaysGeTbigintBigintLogicalFunction.hpp | 54 ++++++ .../AlwaysGtTbigintBigintLogicalFunction.hpp | 54 ++++++ .../AlwaysLeTbigintBigintLogicalFunction.hpp | 54 ++++++ .../AlwaysLtTbigintBigintLogicalFunction.hpp | 54 ++++++ .../AlwaysNeTbigintBigintLogicalFunction.hpp | 54 ++++++ .../AlwaysEqTbigintBigintLogicalFunction.cpp | 105 ++++++++++ .../AlwaysGeTbigintBigintLogicalFunction.cpp | 105 ++++++++++ .../AlwaysGtTbigintBigintLogicalFunction.cpp | 105 ++++++++++ .../AlwaysLeTbigintBigintLogicalFunction.cpp | 105 ++++++++++ .../AlwaysLtTbigintBigintLogicalFunction.cpp | 105 ++++++++++ .../AlwaysNeTbigintBigintLogicalFunction.cpp | 105 ++++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../AlwaysEqTbigintBigintPhysicalFunction.hpp | 43 +++++ .../AlwaysGeTbigintBigintPhysicalFunction.hpp | 43 +++++ .../AlwaysGtTbigintBigintPhysicalFunction.hpp | 43 +++++ .../AlwaysLeTbigintBigintPhysicalFunction.hpp | 43 +++++ .../AlwaysLtTbigintBigintPhysicalFunction.hpp | 43 +++++ .../AlwaysNeTbigintBigintPhysicalFunction.hpp | 43 +++++ .../AlwaysEqTbigintBigintPhysicalFunction.cpp | 88 +++++++++ .../AlwaysGeTbigintBigintPhysicalFunction.cpp | 88 +++++++++ .../AlwaysGtTbigintBigintPhysicalFunction.cpp | 88 +++++++++ .../AlwaysLeTbigintBigintPhysicalFunction.cpp | 88 +++++++++ .../AlwaysLtTbigintBigintPhysicalFunction.cpp | 88 +++++++++ .../AlwaysNeTbigintBigintPhysicalFunction.cpp | 88 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 180 ++++++++++++++++++ 28 files changed, 1939 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGeTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGtTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLeTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLtTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTbigintBigintLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTbigintBigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGeTbigintBigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGtTbigintBigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLeTbigintBigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLtTbigintBigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTbigintBigintLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGeTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGtTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLeTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLtTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTbigintBigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTbigintBigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGeTbigintBigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGtTbigintBigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLeTbigintBigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLtTbigintBigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTbigintBigintPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..73cacef859 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_eq_tbigint_bigint: tests if a single-instant tbigint value always eqs a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_eq_tbigint_bigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysEqTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTbigintBigint"; + + AlwaysEqTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..a31094c055 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ge_tbigint_bigint: tests if a single-instant tbigint value always ges a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ge_tbigint_bigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGeTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGeTbigintBigint"; + + AlwaysGeTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..545679adb1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_gt_tbigint_bigint: tests if a single-instant tbigint value always gts a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_gt_tbigint_bigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGtTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGtTbigintBigint"; + + AlwaysGtTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..4a536e136f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_le_tbigint_bigint: tests if a single-instant tbigint value always les a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_le_tbigint_bigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLeTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLeTbigintBigint"; + + AlwaysLeTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..6f59e4f7d2 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_lt_tbigint_bigint: tests if a single-instant tbigint value always lts a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_lt_tbigint_bigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLtTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLtTbigintBigint"; + + AlwaysLtTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTbigintBigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTbigintBigintLogicalFunction.hpp new file mode 100644 index 0000000000..34d9e07bff --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTbigintBigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ne_tbigint_bigint: tests if a single-instant tbigint value always nes a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ne_tbigint_bigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysNeTbigintBigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTbigintBigint"; + + AlwaysNeTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..98b2a73558 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTbigintBigintLogicalFunction::AlwaysEqTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysEqTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysEqTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysEqTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysEqTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..d433b0175f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGeTbigintBigintLogicalFunction::AlwaysGeTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGeTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGeTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGeTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGeTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGeTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGeTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool AlwaysGeTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGeTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGeTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGeTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGeTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGeTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..3bd42528ad --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGtTbigintBigintLogicalFunction::AlwaysGtTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGtTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGtTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGtTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGtTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGtTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGtTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool AlwaysGtTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGtTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGtTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGtTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGtTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGtTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..86223eed0a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLeTbigintBigintLogicalFunction::AlwaysLeTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLeTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLeTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLeTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLeTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLeTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLeTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool AlwaysLeTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLeTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLeTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLeTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLeTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLeTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..404fab0558 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLtTbigintBigintLogicalFunction::AlwaysLtTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLtTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLtTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLtTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLtTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLtTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLtTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool AlwaysLtTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLtTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLtTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLtTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLtTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLtTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTbigintBigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTbigintBigintLogicalFunction.cpp new file mode 100644 index 0000000000..f6ff33b4c6 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTbigintBigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTbigintBigintLogicalFunction::AlwaysNeTbigintBigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeTbigintBigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTbigintBigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTbigintBigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTbigintBigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysNeTbigintBigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTbigintBigintLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTbigintBigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTbigintBigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysNeTbigintBigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysNeTbigintBigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTbigintBigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeTbigintBigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysNeTbigintBigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 27a547c802..3eeb41115c 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -106,3 +106,9 @@ add_plugin(EverGtTbigintBigint LogicalFunction nes-logical-operators EverGtTbigi add_plugin(EverLeTbigintBigint LogicalFunction nes-logical-operators EverLeTbigintBigintLogicalFunction.cpp) add_plugin(EverLtTbigintBigint LogicalFunction nes-logical-operators EverLtTbigintBigintLogicalFunction.cpp) add_plugin(EverNeTbigintBigint LogicalFunction nes-logical-operators EverNeTbigintBigintLogicalFunction.cpp) +add_plugin(AlwaysEqTbigintBigint LogicalFunction nes-logical-operators AlwaysEqTbigintBigintLogicalFunction.cpp) +add_plugin(AlwaysGeTbigintBigint LogicalFunction nes-logical-operators AlwaysGeTbigintBigintLogicalFunction.cpp) +add_plugin(AlwaysGtTbigintBigint LogicalFunction nes-logical-operators AlwaysGtTbigintBigintLogicalFunction.cpp) +add_plugin(AlwaysLeTbigintBigint LogicalFunction nes-logical-operators AlwaysLeTbigintBigintLogicalFunction.cpp) +add_plugin(AlwaysLtTbigintBigint LogicalFunction nes-logical-operators AlwaysLtTbigintBigintLogicalFunction.cpp) +add_plugin(AlwaysNeTbigintBigint LogicalFunction nes-logical-operators AlwaysNeTbigintBigintLogicalFunction.cpp) diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..1a2954e0d9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_eq_tbigint_bigint`. + * + * Per-event always_eq_tbigint_bigint: tests if a single-instant tbigint value always eqs a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysEqTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..696a10033e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ge_tbigint_bigint`. + * + * Per-event always_ge_tbigint_bigint: tests if a single-instant tbigint value always ges a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGeTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGeTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..057d173cb8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_gt_tbigint_bigint`. + * + * Per-event always_gt_tbigint_bigint: tests if a single-instant tbigint value always gts a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGtTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGtTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..7eaec26d2a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_le_tbigint_bigint`. + * + * Per-event always_le_tbigint_bigint: tests if a single-instant tbigint value always les a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLeTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLeTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..576af1c9b3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_lt_tbigint_bigint`. + * + * Per-event always_lt_tbigint_bigint: tests if a single-instant tbigint value always lts a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLtTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLtTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTbigintBigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTbigintBigintPhysicalFunction.hpp new file mode 100644 index 0000000000..3841644db4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTbigintBigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ne_tbigint_bigint`. + * + * Per-event always_ne_tbigint_bigint: tests if a single-instant tbigint value always nes a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysNeTbigintBigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..83f88e654b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTbigintBigintPhysicalFunction::AlwaysEqTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_eq_tbigint_bigint(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysEqTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..d16a0b080a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGeTbigintBigintPhysicalFunction::AlwaysGeTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGeTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_ge_tbigint_bigint(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGeTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGeTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGeTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..e1fd28cdb2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGtTbigintBigintPhysicalFunction::AlwaysGtTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGtTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_gt_tbigint_bigint(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGtTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGtTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGtTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..18083698c0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLeTbigintBigintPhysicalFunction::AlwaysLeTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLeTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_le_tbigint_bigint(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLeTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLeTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLeTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..1c222e3c3f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLtTbigintBigintPhysicalFunction::AlwaysLtTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLtTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_lt_tbigint_bigint(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLtTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLtTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLtTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTbigintBigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTbigintBigintPhysicalFunction.cpp new file mode 100644 index 0000000000..b8848188c2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTbigintBigintPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTbigintBigintPhysicalFunction::AlwaysNeTbigintBigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeTbigintBigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double value, double threshold, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string tempWkt = fmt::format("{}@{}", static_cast(value), MEOS::Meos::convertEpochToTimestamp(ts)); + Temporal* temp = tbigint_in(tempWkt.c_str()); + if (!temp) return 0.0; + int r = always_ne_tbigint_bigint(temp, static_cast(threshold)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTbigintBigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeTbigintBigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysNeTbigintBigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 340d0c6aaa..9f732075af 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -105,4 +105,10 @@ add_plugin(EverGtTbigintBigint PhysicalFunction nes-physical-operators EverGtTbi add_plugin(EverLeTbigintBigint PhysicalFunction nes-physical-operators EverLeTbigintBigintPhysicalFunction.cpp) add_plugin(EverLtTbigintBigint PhysicalFunction nes-physical-operators EverLtTbigintBigintPhysicalFunction.cpp) add_plugin(EverNeTbigintBigint PhysicalFunction nes-physical-operators EverNeTbigintBigintPhysicalFunction.cpp) +add_plugin(AlwaysEqTbigintBigint PhysicalFunction nes-physical-operators AlwaysEqTbigintBigintPhysicalFunction.cpp) +add_plugin(AlwaysGeTbigintBigint PhysicalFunction nes-physical-operators AlwaysGeTbigintBigintPhysicalFunction.cpp) +add_plugin(AlwaysGtTbigintBigint PhysicalFunction nes-physical-operators AlwaysGtTbigintBigintPhysicalFunction.cpp) +add_plugin(AlwaysLeTbigintBigint PhysicalFunction nes-physical-operators AlwaysLeTbigintBigintPhysicalFunction.cpp) +add_plugin(AlwaysLtTbigintBigint PhysicalFunction nes-physical-operators AlwaysLtTbigintBigintPhysicalFunction.cpp) +add_plugin(AlwaysNeTbigintBigint PhysicalFunction nes-physical-operators AlwaysNeTbigintBigintPhysicalFunction.cpp) endif() diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 8866198a2d..b753ebd7cd 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -486,6 +486,12 @@ TEMPORAL_SEQUENCE: 'TEMPORAL_SEQUENCE' | 'temporal_sequence'; TEMPORAL_EINTERSECTS_GEOMETRY: 'TEMPORAL_EINTERSECTS_GEOMETRY' | 'temporal_eintersects_geometry'; TEMPORAL_AINTERSECTS_GEOMETRY: 'TEMPORAL_AINTERSECTS_GEOMETRY' | 'temporal_aintersects_geometry'; TEMPORAL_ECONTAINS_GEOMETRY: 'TEMPORAL_ECONTAINS_GEOMETRY' | 'temporal_econtains_geometry'; +ALWAYS_EQ_TBIGINT_BIGINT: 'ALWAYS_EQ_TBIGINT_BIGINT' | 'always_eq_tbigint_bigint'; +ALWAYS_GE_TBIGINT_BIGINT: 'ALWAYS_GE_TBIGINT_BIGINT' | 'always_ge_tbigint_bigint'; +ALWAYS_GT_TBIGINT_BIGINT: 'ALWAYS_GT_TBIGINT_BIGINT' | 'always_gt_tbigint_bigint'; +ALWAYS_LE_TBIGINT_BIGINT: 'ALWAYS_LE_TBIGINT_BIGINT' | 'always_le_tbigint_bigint'; +ALWAYS_LT_TBIGINT_BIGINT: 'ALWAYS_LT_TBIGINT_BIGINT' | 'always_lt_tbigint_bigint'; +ALWAYS_NE_TBIGINT_BIGINT: 'ALWAYS_NE_TBIGINT_BIGINT' | 'always_ne_tbigint_bigint'; ALWAYS_EQ_TFLOAT_FLOAT: 'ALWAYS_EQ_TFLOAT_FLOAT' | 'always_eq_tfloat_float'; ALWAYS_GE_TFLOAT_FLOAT: 'ALWAYS_GE_TFLOAT_FLOAT' | 'always_ge_tfloat_float'; ALWAYS_GT_TFLOAT_FLOAT: 'ALWAYS_GT_TFLOAT_FLOAT' | 'always_gt_tfloat_float'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index f1b94976e1..3f76393001 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -133,6 +133,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -3640,6 +3646,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: ALWAYS_NE_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TBIGINT_BIGINT */ + case AntlrSQLLexer::ALWAYS_EQ_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GE_TBIGINT_BIGINT */ + case AntlrSQLLexer::ALWAYS_GE_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GE_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGeTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GE_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GT_TBIGINT_BIGINT */ + case AntlrSQLLexer::ALWAYS_GT_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GT_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGtTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GT_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LE_TBIGINT_BIGINT */ + case AntlrSQLLexer::ALWAYS_LE_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LE_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLeTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LE_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LT_TBIGINT_BIGINT */ + case AntlrSQLLexer::ALWAYS_LT_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LT_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLtTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LT_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_TBIGINT_BIGINT */ + case AntlrSQLLexer::ALWAYS_NE_TBIGINT_BIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_NE_TBIGINT_BIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysNeTbigintBigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TBIGINT_BIGINT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 255e579a6eb8874374caa7c3c570e25ad5ab47e5 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 09:46:22 +0200 Subject: [PATCH 25/86] feat(meos): add EVER_EQ/GE/GT/LE/LT/NE_TFLOAT_TFLOAT NES operators (W67) --- .../EverEqTfloatTfloatLogicalFunction.hpp | 54 ++++++ .../EverGeTfloatTfloatLogicalFunction.hpp | 54 ++++++ .../EverGtTfloatTfloatLogicalFunction.hpp | 54 ++++++ .../EverLeTfloatTfloatLogicalFunction.hpp | 54 ++++++ .../EverLtTfloatTfloatLogicalFunction.hpp | 54 ++++++ .../EverNeTfloatTfloatLogicalFunction.hpp | 54 ++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../EverEqTfloatTfloatLogicalFunction.cpp | 105 ++++++++++ .../EverGeTfloatTfloatLogicalFunction.cpp | 105 ++++++++++ .../EverGtTfloatTfloatLogicalFunction.cpp | 105 ++++++++++ .../EverLeTfloatTfloatLogicalFunction.cpp | 105 ++++++++++ .../EverLtTfloatTfloatLogicalFunction.cpp | 105 ++++++++++ .../EverNeTfloatTfloatLogicalFunction.cpp | 105 ++++++++++ .../EverEqTfloatTfloatPhysicalFunction.hpp | 43 +++++ .../EverGeTfloatTfloatPhysicalFunction.hpp | 43 +++++ .../EverGtTfloatTfloatPhysicalFunction.hpp | 43 +++++ .../EverLeTfloatTfloatPhysicalFunction.hpp | 43 +++++ .../EverLtTfloatTfloatPhysicalFunction.hpp | 43 +++++ .../EverNeTfloatTfloatPhysicalFunction.hpp | 43 +++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../EverEqTfloatTfloatPhysicalFunction.cpp | 93 +++++++++ .../EverGeTfloatTfloatPhysicalFunction.cpp | 93 +++++++++ .../EverGtTfloatTfloatPhysicalFunction.cpp | 93 +++++++++ .../EverLeTfloatTfloatPhysicalFunction.cpp | 93 +++++++++ .../EverLtTfloatTfloatPhysicalFunction.cpp | 93 +++++++++ .../EverNeTfloatTfloatPhysicalFunction.cpp | 93 +++++++++ nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 180 ++++++++++++++++++ 28 files changed, 1969 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTfloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGeTfloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGtTfloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLeTfloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLtTfloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTfloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTfloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGeTfloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGtTfloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLeTfloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLtTfloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTfloatTfloatLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTfloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGeTfloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGtTfloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLeTfloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLtTfloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTfloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTfloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGeTfloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGtTfloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLeTfloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLtTfloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTfloatTfloatPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTfloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTfloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..2443348121 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTfloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_eq_tfloat_tfloat: tests if two single-instant tfloat values are ever equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_eq_tfloat_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverEqTfloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTfloatTfloat"; + + EverEqTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGeTfloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeTfloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..11ea682b4a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGeTfloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ge_tfloat_tfloat: tests if a single-instant tfloat value is ever >= another. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ge_tfloat_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGeTfloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGeTfloatTfloat"; + + EverGeTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGtTfloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtTfloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..205f5637b5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGtTfloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_gt_tfloat_tfloat: tests if a single-instant tfloat value is ever > another. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_gt_tfloat_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGtTfloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGtTfloatTfloat"; + + EverGtTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLeTfloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeTfloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..9cf126509e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLeTfloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_le_tfloat_tfloat: tests if a single-instant tfloat value is ever <= another. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_le_tfloat_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLeTfloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLeTfloatTfloat"; + + EverLeTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLtTfloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtTfloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..fe27023924 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLtTfloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_lt_tfloat_tfloat: tests if a single-instant tfloat value is ever < another. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_lt_tfloat_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLtTfloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLtTfloatTfloat"; + + EverLtTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTfloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTfloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..91ca1b6e82 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTfloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ne_tfloat_tfloat: tests if two single-instant tfloat values are ever not equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ne_tfloat_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverNeTfloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTfloatTfloat"; + + EverNeTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 3eeb41115c..b80b84b37f 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -112,3 +112,9 @@ add_plugin(AlwaysGtTbigintBigint LogicalFunction nes-logical-operators AlwaysGtT add_plugin(AlwaysLeTbigintBigint LogicalFunction nes-logical-operators AlwaysLeTbigintBigintLogicalFunction.cpp) add_plugin(AlwaysLtTbigintBigint LogicalFunction nes-logical-operators AlwaysLtTbigintBigintLogicalFunction.cpp) add_plugin(AlwaysNeTbigintBigint LogicalFunction nes-logical-operators AlwaysNeTbigintBigintLogicalFunction.cpp) +add_plugin(EverEqTfloatTfloat LogicalFunction nes-logical-operators EverEqTfloatTfloatLogicalFunction.cpp) +add_plugin(EverGeTfloatTfloat LogicalFunction nes-logical-operators EverGeTfloatTfloatLogicalFunction.cpp) +add_plugin(EverGtTfloatTfloat LogicalFunction nes-logical-operators EverGtTfloatTfloatLogicalFunction.cpp) +add_plugin(EverLeTfloatTfloat LogicalFunction nes-logical-operators EverLeTfloatTfloatLogicalFunction.cpp) +add_plugin(EverLtTfloatTfloat LogicalFunction nes-logical-operators EverLtTfloatTfloatLogicalFunction.cpp) +add_plugin(EverNeTfloatTfloat LogicalFunction nes-logical-operators EverNeTfloatTfloatLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTfloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTfloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..1cfd5aa230 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTfloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTfloatTfloatLogicalFunction::EverEqTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqTfloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTfloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTfloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTfloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverEqTfloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTfloatTfloatLogicalFunction::getType() const { return NAME; } + +bool EverEqTfloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTfloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverEqTfloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverEqTfloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTfloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqTfloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverEqTfloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeTfloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeTfloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..c715da9225 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGeTfloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGeTfloatTfloatLogicalFunction::EverGeTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverGeTfloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGeTfloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGeTfloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGeTfloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGeTfloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGeTfloatTfloatLogicalFunction::getType() const { return NAME; } + +bool EverGeTfloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGeTfloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGeTfloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGeTfloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeTfloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGeTfloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGeTfloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtTfloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtTfloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..efed7082b8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGtTfloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGtTfloatTfloatLogicalFunction::EverGtTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverGtTfloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGtTfloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGtTfloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGtTfloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGtTfloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGtTfloatTfloatLogicalFunction::getType() const { return NAME; } + +bool EverGtTfloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGtTfloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGtTfloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGtTfloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtTfloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGtTfloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGtTfloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeTfloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeTfloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..3cbc28baab --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLeTfloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLeTfloatTfloatLogicalFunction::EverLeTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverLeTfloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLeTfloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLeTfloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLeTfloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLeTfloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLeTfloatTfloatLogicalFunction::getType() const { return NAME; } + +bool EverLeTfloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLeTfloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLeTfloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLeTfloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeTfloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLeTfloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLeTfloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtTfloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtTfloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..316aad8049 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLtTfloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLtTfloatTfloatLogicalFunction::EverLtTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverLtTfloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLtTfloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLtTfloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLtTfloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLtTfloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLtTfloatTfloatLogicalFunction::getType() const { return NAME; } + +bool EverLtTfloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLtTfloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLtTfloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLtTfloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtTfloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLtTfloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLtTfloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTfloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTfloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..fbfa005278 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTfloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTfloatTfloatLogicalFunction::EverNeTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeTfloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTfloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTfloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTfloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverNeTfloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTfloatTfloatLogicalFunction::getType() const { return NAME; } + +bool EverNeTfloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTfloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverNeTfloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverNeTfloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTfloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeTfloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverNeTfloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTfloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTfloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..eeff2788fc --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTfloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_eq_tfloat_tfloat`. + * + * Per-event ever_eq_tfloat_tfloat: tests if two single-instant tfloat values are ever equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverEqTfloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGeTfloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeTfloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..59b68f7814 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGeTfloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ge_tfloat_tfloat`. + * + * Per-event ever_ge_tfloat_tfloat: tests if a single-instant tfloat value is ever >= another. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGeTfloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGeTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGtTfloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtTfloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..37d9efc312 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGtTfloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_gt_tfloat_tfloat`. + * + * Per-event ever_gt_tfloat_tfloat: tests if a single-instant tfloat value is ever > another. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGtTfloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGtTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLeTfloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeTfloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..c654b70c34 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLeTfloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_le_tfloat_tfloat`. + * + * Per-event ever_le_tfloat_tfloat: tests if a single-instant tfloat value is ever <= another. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLeTfloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLeTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLtTfloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtTfloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..abdae5a08c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLtTfloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_lt_tfloat_tfloat`. + * + * Per-event ever_lt_tfloat_tfloat: tests if a single-instant tfloat value is ever < another. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLtTfloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLtTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTfloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTfloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..b442c9ac73 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTfloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ne_tfloat_tfloat`. + * + * Per-event ever_ne_tfloat_tfloat: tests if two single-instant tfloat values are ever not equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverNeTfloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 9f732075af..87a11b5c6d 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -111,4 +111,10 @@ add_plugin(AlwaysGtTbigintBigint PhysicalFunction nes-physical-operators AlwaysG add_plugin(AlwaysLeTbigintBigint PhysicalFunction nes-physical-operators AlwaysLeTbigintBigintPhysicalFunction.cpp) add_plugin(AlwaysLtTbigintBigint PhysicalFunction nes-physical-operators AlwaysLtTbigintBigintPhysicalFunction.cpp) add_plugin(AlwaysNeTbigintBigint PhysicalFunction nes-physical-operators AlwaysNeTbigintBigintPhysicalFunction.cpp) +add_plugin(EverEqTfloatTfloat PhysicalFunction nes-physical-operators EverEqTfloatTfloatPhysicalFunction.cpp) +add_plugin(EverGeTfloatTfloat PhysicalFunction nes-physical-operators EverGeTfloatTfloatPhysicalFunction.cpp) +add_plugin(EverGtTfloatTfloat PhysicalFunction nes-physical-operators EverGtTfloatTfloatPhysicalFunction.cpp) +add_plugin(EverLeTfloatTfloat PhysicalFunction nes-physical-operators EverLeTfloatTfloatPhysicalFunction.cpp) +add_plugin(EverLtTfloatTfloat PhysicalFunction nes-physical-operators EverLtTfloatTfloatPhysicalFunction.cpp) +add_plugin(EverNeTfloatTfloat PhysicalFunction nes-physical-operators EverNeTfloatTfloatPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTfloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTfloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..4211654b15 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTfloatTfloatPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTfloatTfloatPhysicalFunction::EverEqTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverEqTfloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_eq_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTfloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqTfloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverEqTfloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGeTfloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeTfloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..181aff3ead --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGeTfloatTfloatPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGeTfloatTfloatPhysicalFunction::EverGeTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGeTfloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_ge_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGeTfloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGeTfloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGeTfloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGtTfloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtTfloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..54c921b2ca --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGtTfloatTfloatPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGtTfloatTfloatPhysicalFunction::EverGtTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGtTfloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_gt_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGtTfloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGtTfloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGtTfloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLeTfloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeTfloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..9a5c3cdd9b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLeTfloatTfloatPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLeTfloatTfloatPhysicalFunction::EverLeTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLeTfloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_le_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLeTfloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLeTfloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLeTfloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLtTfloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtTfloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..83f62a4375 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLtTfloatTfloatPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLtTfloatTfloatPhysicalFunction::EverLtTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLtTfloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_lt_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLtTfloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLtTfloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLtTfloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTfloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTfloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..5e1aa3ad57 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTfloatTfloatPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTfloatTfloatPhysicalFunction::EverNeTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverNeTfloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_ne_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTfloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeTfloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverNeTfloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index b753ebd7cd..f05a26eed2 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -517,6 +517,12 @@ EVER_GT_TFLOAT_FLOAT: 'EVER_GT_TFLOAT_FLOAT' | 'ever_gt_tfloat_float'; EVER_LE_TFLOAT_FLOAT: 'EVER_LE_TFLOAT_FLOAT' | 'ever_le_tfloat_float'; EVER_LT_TFLOAT_FLOAT: 'EVER_LT_TFLOAT_FLOAT' | 'ever_lt_tfloat_float'; EVER_NE_TFLOAT_FLOAT: 'EVER_NE_TFLOAT_FLOAT' | 'ever_ne_tfloat_float'; +EVER_EQ_TFLOAT_TFLOAT: 'EVER_EQ_TFLOAT_TFLOAT' | 'ever_eq_tfloat_tfloat'; +EVER_GE_TFLOAT_TFLOAT: 'EVER_GE_TFLOAT_TFLOAT' | 'ever_ge_tfloat_tfloat'; +EVER_GT_TFLOAT_TFLOAT: 'EVER_GT_TFLOAT_TFLOAT' | 'ever_gt_tfloat_tfloat'; +EVER_LE_TFLOAT_TFLOAT: 'EVER_LE_TFLOAT_TFLOAT' | 'ever_le_tfloat_tfloat'; +EVER_LT_TFLOAT_TFLOAT: 'EVER_LT_TFLOAT_TFLOAT' | 'ever_lt_tfloat_tfloat'; +EVER_NE_TFLOAT_TFLOAT: 'EVER_NE_TFLOAT_TFLOAT' | 'ever_ne_tfloat_tfloat'; EVER_EQ_TINT_INT: 'EVER_EQ_TINT_INT' | 'ever_eq_tint_int'; EVER_GE_TINT_INT: 'EVER_GE_TINT_INT' | 'ever_ge_tint_int'; EVER_GT_TINT_INT: 'EVER_GT_TINT_INT' | 'ever_gt_tint_int'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 3f76393001..416af8aba6 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -145,6 +145,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -3298,6 +3304,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: EVER_NE_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TFLOAT_TFLOAT */ + case AntlrSQLLexer::EVER_EQ_TFLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_TFLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqTfloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_TFLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GE_TFLOAT_TFLOAT */ + case AntlrSQLLexer::EVER_GE_TFLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GE_TFLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGeTfloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GE_TFLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GT_TFLOAT_TFLOAT */ + case AntlrSQLLexer::EVER_GT_TFLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GT_TFLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGtTfloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GT_TFLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LE_TFLOAT_TFLOAT */ + case AntlrSQLLexer::EVER_LE_TFLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LE_TFLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLeTfloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LE_TFLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LT_TFLOAT_TFLOAT */ + case AntlrSQLLexer::EVER_LT_TFLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LT_TFLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLtTfloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LT_TFLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_TFLOAT_TFLOAT */ + case AntlrSQLLexer::EVER_NE_TFLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_TFLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeTfloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_NE_TFLOAT_TFLOAT */ /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TINT_INT */ case AntlrSQLLexer::EVER_EQ_TINT_INT: { From 5331eb22da29bf6da81904e96af14054c674ad9f Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 09:48:35 +0200 Subject: [PATCH 26/86] feat(meos): add ALWAYS_EQ/GE/GT/LE/LT/NE_TFLOAT_TFLOAT NES operators (W68) --- .../AlwaysEqTfloatTfloatLogicalFunction.hpp | 54 ++++++ .../AlwaysGeTfloatTfloatLogicalFunction.hpp | 54 ++++++ .../AlwaysGtTfloatTfloatLogicalFunction.hpp | 54 ++++++ .../AlwaysLeTfloatTfloatLogicalFunction.hpp | 54 ++++++ .../AlwaysLtTfloatTfloatLogicalFunction.hpp | 54 ++++++ .../AlwaysNeTfloatTfloatLogicalFunction.hpp | 54 ++++++ .../AlwaysEqTfloatTfloatLogicalFunction.cpp | 105 ++++++++++ .../AlwaysGeTfloatTfloatLogicalFunction.cpp | 105 ++++++++++ .../AlwaysGtTfloatTfloatLogicalFunction.cpp | 105 ++++++++++ .../AlwaysLeTfloatTfloatLogicalFunction.cpp | 105 ++++++++++ .../AlwaysLtTfloatTfloatLogicalFunction.cpp | 105 ++++++++++ .../AlwaysNeTfloatTfloatLogicalFunction.cpp | 105 ++++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../AlwaysEqTfloatTfloatPhysicalFunction.hpp | 43 +++++ .../AlwaysGeTfloatTfloatPhysicalFunction.hpp | 43 +++++ .../AlwaysGtTfloatTfloatPhysicalFunction.hpp | 43 +++++ .../AlwaysLeTfloatTfloatPhysicalFunction.hpp | 43 +++++ .../AlwaysLtTfloatTfloatPhysicalFunction.hpp | 43 +++++ .../AlwaysNeTfloatTfloatPhysicalFunction.hpp | 43 +++++ .../AlwaysEqTfloatTfloatPhysicalFunction.cpp | 93 +++++++++ .../AlwaysGeTfloatTfloatPhysicalFunction.cpp | 93 +++++++++ .../AlwaysGtTfloatTfloatPhysicalFunction.cpp | 93 +++++++++ .../AlwaysLeTfloatTfloatPhysicalFunction.cpp | 93 +++++++++ .../AlwaysLtTfloatTfloatPhysicalFunction.cpp | 93 +++++++++ .../AlwaysNeTfloatTfloatPhysicalFunction.cpp | 93 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 180 ++++++++++++++++++ 28 files changed, 1969 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTfloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGeTfloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGtTfloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLeTfloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLtTfloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTfloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTfloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGeTfloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGtTfloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLeTfloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLtTfloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTfloatTfloatLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTfloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGeTfloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGtTfloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLeTfloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLtTfloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTfloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTfloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGeTfloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGtTfloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLeTfloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLtTfloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTfloatTfloatPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTfloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTfloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..8f3bf14907 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTfloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_eq_tfloat_tfloat: tests if two single-instant tfloat values are always equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_eq_tfloat_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysEqTfloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTfloatTfloat"; + + AlwaysEqTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeTfloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeTfloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..c28f61b9d0 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeTfloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ge_tfloat_tfloat: tests if two single-instant tfloat values are always greater or equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ge_tfloat_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGeTfloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGeTfloatTfloat"; + + AlwaysGeTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtTfloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtTfloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..bb6e69d20c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtTfloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_gt_tfloat_tfloat: tests if two single-instant tfloat values are always greater than. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_gt_tfloat_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGtTfloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGtTfloatTfloat"; + + AlwaysGtTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeTfloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeTfloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..e0da946b69 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeTfloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_le_tfloat_tfloat: tests if two single-instant tfloat values are always less or equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_le_tfloat_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLeTfloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLeTfloatTfloat"; + + AlwaysLeTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtTfloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtTfloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..b230fad6a6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtTfloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_lt_tfloat_tfloat: tests if two single-instant tfloat values are always less than. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_lt_tfloat_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLtTfloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLtTfloatTfloat"; + + AlwaysLtTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTfloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTfloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..89a2173d8b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTfloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ne_tfloat_tfloat: tests if two single-instant tfloat values are always not equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ne_tfloat_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysNeTfloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTfloatTfloat"; + + AlwaysNeTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTfloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTfloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..ac2546cc62 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTfloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTfloatTfloatLogicalFunction::AlwaysEqTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqTfloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTfloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTfloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTfloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysEqTfloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTfloatTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTfloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTfloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysEqTfloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysEqTfloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTfloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqTfloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysEqTfloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeTfloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeTfloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..fb64432927 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeTfloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGeTfloatTfloatLogicalFunction::AlwaysGeTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGeTfloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGeTfloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGeTfloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGeTfloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGeTfloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGeTfloatTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysGeTfloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGeTfloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGeTfloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGeTfloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeTfloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGeTfloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGeTfloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtTfloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtTfloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..8ca501b834 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtTfloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGtTfloatTfloatLogicalFunction::AlwaysGtTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGtTfloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGtTfloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGtTfloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGtTfloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGtTfloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGtTfloatTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysGtTfloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGtTfloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGtTfloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGtTfloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtTfloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGtTfloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGtTfloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeTfloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeTfloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..ac3b1f7bd5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeTfloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLeTfloatTfloatLogicalFunction::AlwaysLeTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLeTfloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLeTfloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLeTfloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLeTfloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLeTfloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLeTfloatTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysLeTfloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLeTfloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLeTfloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLeTfloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeTfloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLeTfloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLeTfloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtTfloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtTfloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..d8ca815dbb --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtTfloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLtTfloatTfloatLogicalFunction::AlwaysLtTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLtTfloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLtTfloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLtTfloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLtTfloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLtTfloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLtTfloatTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysLtTfloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLtTfloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLtTfloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLtTfloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtTfloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLtTfloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLtTfloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTfloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTfloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..7ca2a0efa2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTfloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTfloatTfloatLogicalFunction::AlwaysNeTfloatTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeTfloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTfloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTfloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTfloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysNeTfloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTfloatTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTfloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTfloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysNeTfloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysNeTfloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTfloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeTfloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysNeTfloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index b80b84b37f..05b6e980fa 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -118,3 +118,9 @@ add_plugin(EverGtTfloatTfloat LogicalFunction nes-logical-operators EverGtTfloat add_plugin(EverLeTfloatTfloat LogicalFunction nes-logical-operators EverLeTfloatTfloatLogicalFunction.cpp) add_plugin(EverLtTfloatTfloat LogicalFunction nes-logical-operators EverLtTfloatTfloatLogicalFunction.cpp) add_plugin(EverNeTfloatTfloat LogicalFunction nes-logical-operators EverNeTfloatTfloatLogicalFunction.cpp) +add_plugin(AlwaysEqTfloatTfloat LogicalFunction nes-logical-operators AlwaysEqTfloatTfloatLogicalFunction.cpp) +add_plugin(AlwaysGeTfloatTfloat LogicalFunction nes-logical-operators AlwaysGeTfloatTfloatLogicalFunction.cpp) +add_plugin(AlwaysGtTfloatTfloat LogicalFunction nes-logical-operators AlwaysGtTfloatTfloatLogicalFunction.cpp) +add_plugin(AlwaysLeTfloatTfloat LogicalFunction nes-logical-operators AlwaysLeTfloatTfloatLogicalFunction.cpp) +add_plugin(AlwaysLtTfloatTfloat LogicalFunction nes-logical-operators AlwaysLtTfloatTfloatLogicalFunction.cpp) +add_plugin(AlwaysNeTfloatTfloat LogicalFunction nes-logical-operators AlwaysNeTfloatTfloatLogicalFunction.cpp) diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTfloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTfloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..fe0a51875f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTfloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_eq_tfloat_tfloat`. + * + * Per-event always_eq_tfloat_tfloat: tests if two single-instant tfloat values are always equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysEqTfloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeTfloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeTfloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..41c3741fa8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeTfloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ge_tfloat_tfloat`. + * + * Per-event always_ge_tfloat_tfloat: tests if two single-instant tfloat values are always greater or equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGeTfloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGeTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtTfloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtTfloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..61431a3674 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtTfloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_gt_tfloat_tfloat`. + * + * Per-event always_gt_tfloat_tfloat: tests if two single-instant tfloat values are always greater than. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGtTfloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGtTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeTfloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeTfloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..fcd7715d02 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeTfloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_le_tfloat_tfloat`. + * + * Per-event always_le_tfloat_tfloat: tests if two single-instant tfloat values are always less or equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLeTfloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLeTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtTfloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtTfloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..7a56b6e4f1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtTfloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_lt_tfloat_tfloat`. + * + * Per-event always_lt_tfloat_tfloat: tests if two single-instant tfloat values are always less than. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLtTfloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLtTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTfloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTfloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..18664359c9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTfloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ne_tfloat_tfloat`. + * + * Per-event always_ne_tfloat_tfloat: tests if two single-instant tfloat values are always not equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysNeTfloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTfloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTfloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..ef558c5852 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTfloatTfloatPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTfloatTfloatPhysicalFunction::AlwaysEqTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqTfloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_eq_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTfloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqTfloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysEqTfloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeTfloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeTfloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..d9f7980962 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeTfloatTfloatPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGeTfloatTfloatPhysicalFunction::AlwaysGeTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGeTfloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_ge_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGeTfloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGeTfloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGeTfloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtTfloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtTfloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..9a584369b0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtTfloatTfloatPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGtTfloatTfloatPhysicalFunction::AlwaysGtTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGtTfloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_gt_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGtTfloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGtTfloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGtTfloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeTfloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeTfloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..9871e3830c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeTfloatTfloatPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLeTfloatTfloatPhysicalFunction::AlwaysLeTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLeTfloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_le_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLeTfloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLeTfloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLeTfloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtTfloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtTfloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..fa6bb79689 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtTfloatTfloatPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLtTfloatTfloatPhysicalFunction::AlwaysLtTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLtTfloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_lt_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLtTfloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLtTfloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLtTfloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTfloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTfloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..d8bac764d2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTfloatTfloatPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTfloatTfloatPhysicalFunction::AlwaysNeTfloatTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeTfloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_ne_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTfloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeTfloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysNeTfloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 87a11b5c6d..b085495f7f 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -117,4 +117,10 @@ add_plugin(EverGtTfloatTfloat PhysicalFunction nes-physical-operators EverGtTflo add_plugin(EverLeTfloatTfloat PhysicalFunction nes-physical-operators EverLeTfloatTfloatPhysicalFunction.cpp) add_plugin(EverLtTfloatTfloat PhysicalFunction nes-physical-operators EverLtTfloatTfloatPhysicalFunction.cpp) add_plugin(EverNeTfloatTfloat PhysicalFunction nes-physical-operators EverNeTfloatTfloatPhysicalFunction.cpp) +add_plugin(AlwaysEqTfloatTfloat PhysicalFunction nes-physical-operators AlwaysEqTfloatTfloatPhysicalFunction.cpp) +add_plugin(AlwaysGeTfloatTfloat PhysicalFunction nes-physical-operators AlwaysGeTfloatTfloatPhysicalFunction.cpp) +add_plugin(AlwaysGtTfloatTfloat PhysicalFunction nes-physical-operators AlwaysGtTfloatTfloatPhysicalFunction.cpp) +add_plugin(AlwaysLeTfloatTfloat PhysicalFunction nes-physical-operators AlwaysLeTfloatTfloatPhysicalFunction.cpp) +add_plugin(AlwaysLtTfloatTfloat PhysicalFunction nes-physical-operators AlwaysLtTfloatTfloatPhysicalFunction.cpp) +add_plugin(AlwaysNeTfloatTfloat PhysicalFunction nes-physical-operators AlwaysNeTfloatTfloatPhysicalFunction.cpp) endif() diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index f05a26eed2..6eb4800e5c 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -498,6 +498,12 @@ ALWAYS_GT_TFLOAT_FLOAT: 'ALWAYS_GT_TFLOAT_FLOAT' | 'always_gt_tfloat_float'; ALWAYS_LE_TFLOAT_FLOAT: 'ALWAYS_LE_TFLOAT_FLOAT' | 'always_le_tfloat_float'; ALWAYS_LT_TFLOAT_FLOAT: 'ALWAYS_LT_TFLOAT_FLOAT' | 'always_lt_tfloat_float'; ALWAYS_NE_TFLOAT_FLOAT: 'ALWAYS_NE_TFLOAT_FLOAT' | 'always_ne_tfloat_float'; +ALWAYS_EQ_TFLOAT_TFLOAT: 'ALWAYS_EQ_TFLOAT_TFLOAT' | 'always_eq_tfloat_tfloat'; +ALWAYS_GE_TFLOAT_TFLOAT: 'ALWAYS_GE_TFLOAT_TFLOAT' | 'always_ge_tfloat_tfloat'; +ALWAYS_GT_TFLOAT_TFLOAT: 'ALWAYS_GT_TFLOAT_TFLOAT' | 'always_gt_tfloat_tfloat'; +ALWAYS_LE_TFLOAT_TFLOAT: 'ALWAYS_LE_TFLOAT_TFLOAT' | 'always_le_tfloat_tfloat'; +ALWAYS_LT_TFLOAT_TFLOAT: 'ALWAYS_LT_TFLOAT_TFLOAT' | 'always_lt_tfloat_tfloat'; +ALWAYS_NE_TFLOAT_TFLOAT: 'ALWAYS_NE_TFLOAT_TFLOAT' | 'always_ne_tfloat_tfloat'; ALWAYS_EQ_TINT_INT: 'ALWAYS_EQ_TINT_INT' | 'always_eq_tint_int'; ALWAYS_GE_TINT_INT: 'ALWAYS_GE_TINT_INT' | 'always_ge_tint_int'; ALWAYS_GT_TINT_INT: 'ALWAYS_GT_TINT_INT' | 'always_gt_tint_int'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 416af8aba6..4055e8a63e 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -169,6 +169,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -4174,6 +4180,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: ALWAYS_NE_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_TFLOAT */ + case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_TFLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqTfloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GE_TFLOAT_TFLOAT */ + case AntlrSQLLexer::ALWAYS_GE_TFLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GE_TFLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGeTfloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GE_TFLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GT_TFLOAT_TFLOAT */ + case AntlrSQLLexer::ALWAYS_GT_TFLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GT_TFLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGtTfloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GT_TFLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LE_TFLOAT_TFLOAT */ + case AntlrSQLLexer::ALWAYS_LE_TFLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LE_TFLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLeTfloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LE_TFLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LT_TFLOAT_TFLOAT */ + case AntlrSQLLexer::ALWAYS_LT_TFLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LT_TFLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLtTfloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LT_TFLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_TFLOAT_TFLOAT */ + case AntlrSQLLexer::ALWAYS_NE_TFLOAT_TFLOAT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_NE_TFLOAT_TFLOAT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysNeTfloatTfloatLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TFLOAT_TFLOAT */ default: /// Check if the function is a constructor for a datatype From 604b9130e579887263abca9ab8806494edb17459 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 09:52:29 +0200 Subject: [PATCH 27/86] feat(meos): add EVER_EQ/GE/GT/LE/LT/NE_TINT_TINT NES operators (W69) --- .../Meos/EverEqTintTintLogicalFunction.hpp | 54 ++++++ .../Meos/EverGeTintTintLogicalFunction.hpp | 54 ++++++ .../Meos/EverGtTintTintLogicalFunction.hpp | 54 ++++++ .../Meos/EverLeTintTintLogicalFunction.hpp | 54 ++++++ .../Meos/EverLtTintTintLogicalFunction.hpp | 54 ++++++ .../Meos/EverNeTintTintLogicalFunction.hpp | 54 ++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../Meos/EverEqTintTintLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverGeTintTintLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverGtTintTintLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverLeTintTintLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverLtTintTintLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverNeTintTintLogicalFunction.cpp | 105 ++++++++++ .../Meos/EverEqTintTintPhysicalFunction.hpp | 43 +++++ .../Meos/EverGeTintTintPhysicalFunction.hpp | 43 +++++ .../Meos/EverGtTintTintPhysicalFunction.hpp | 43 +++++ .../Meos/EverLeTintTintPhysicalFunction.hpp | 43 +++++ .../Meos/EverLtTintTintPhysicalFunction.hpp | 43 +++++ .../Meos/EverNeTintTintPhysicalFunction.hpp | 43 +++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../Meos/EverEqTintTintPhysicalFunction.cpp | 93 +++++++++ .../Meos/EverGeTintTintPhysicalFunction.cpp | 93 +++++++++ .../Meos/EverGtTintTintPhysicalFunction.cpp | 93 +++++++++ .../Meos/EverLeTintTintPhysicalFunction.cpp | 93 +++++++++ .../Meos/EverLtTintTintPhysicalFunction.cpp | 93 +++++++++ .../Meos/EverNeTintTintPhysicalFunction.cpp | 93 +++++++++ nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 180 ++++++++++++++++++ 28 files changed, 1969 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTintTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGeTintTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGtTintTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLeTintTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLtTintTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTintTintLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTintTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGeTintTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGtTintTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLeTintTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLtTintTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTintTintLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTintTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGeTintTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGtTintTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLeTintTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLtTintTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTintTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTintTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGeTintTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGtTintTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLeTintTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLtTintTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTintTintPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTintTintLogicalFunction.hpp new file mode 100644 index 0000000000..7ec4f8404c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTintTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_eq_tint_tfloat: tests if two single-instant tint values are ever equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_eq_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverEqTintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTintTfloat"; + + EverEqTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGeTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeTintTintLogicalFunction.hpp new file mode 100644 index 0000000000..c3ecd8b446 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGeTintTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ge_tint_tfloat: tests if two single-instant tint values are ever greater or equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ge_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGeTintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGeTintTfloat"; + + EverGeTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGtTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtTintTintLogicalFunction.hpp new file mode 100644 index 0000000000..03d8dbfcdd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGtTintTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_gt_tint_tfloat: tests if two single-instant tint values are ever greater than. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_gt_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGtTintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGtTintTfloat"; + + EverGtTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLeTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeTintTintLogicalFunction.hpp new file mode 100644 index 0000000000..be4bf55c75 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLeTintTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_le_tint_tfloat: tests if two single-instant tint values are ever less or equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_le_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLeTintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLeTintTfloat"; + + EverLeTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLtTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtTintTintLogicalFunction.hpp new file mode 100644 index 0000000000..094d80a783 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLtTintTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_lt_tint_tfloat: tests if two single-instant tint values are ever less than. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_lt_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLtTintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLtTintTfloat"; + + EverLtTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTintTintLogicalFunction.hpp new file mode 100644 index 0000000000..ae4ac26264 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTintTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ne_tint_tfloat: tests if two single-instant tint values are ever not equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ne_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverNeTintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTintTfloat"; + + EverNeTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 05b6e980fa..0159b5ecb0 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -124,3 +124,9 @@ add_plugin(AlwaysGtTfloatTfloat LogicalFunction nes-logical-operators AlwaysGtTf add_plugin(AlwaysLeTfloatTfloat LogicalFunction nes-logical-operators AlwaysLeTfloatTfloatLogicalFunction.cpp) add_plugin(AlwaysLtTfloatTfloat LogicalFunction nes-logical-operators AlwaysLtTfloatTfloatLogicalFunction.cpp) add_plugin(AlwaysNeTfloatTfloat LogicalFunction nes-logical-operators AlwaysNeTfloatTfloatLogicalFunction.cpp) +add_plugin(EverEqTintTint LogicalFunction nes-logical-operators EverEqTintTintLogicalFunction.cpp) +add_plugin(EverGeTintTint LogicalFunction nes-logical-operators EverGeTintTintLogicalFunction.cpp) +add_plugin(EverGtTintTint LogicalFunction nes-logical-operators EverGtTintTintLogicalFunction.cpp) +add_plugin(EverLeTintTint LogicalFunction nes-logical-operators EverLeTintTintLogicalFunction.cpp) +add_plugin(EverLtTintTint LogicalFunction nes-logical-operators EverLtTintTintLogicalFunction.cpp) +add_plugin(EverNeTintTint LogicalFunction nes-logical-operators EverNeTintTintLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTintTintLogicalFunction.cpp new file mode 100644 index 0000000000..36354c8967 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTintTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTintTfloatLogicalFunction::EverEqTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqTintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverEqTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTintTfloatLogicalFunction::getType() const { return NAME; } + +bool EverEqTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverEqTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverEqTintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqTintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverEqTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeTintTintLogicalFunction.cpp new file mode 100644 index 0000000000..40a41a043e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGeTintTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGeTintTfloatLogicalFunction::EverGeTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverGeTintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGeTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGeTintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGeTintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGeTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGeTintTfloatLogicalFunction::getType() const { return NAME; } + +bool EverGeTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGeTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGeTintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeTintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGeTintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGeTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtTintTintLogicalFunction.cpp new file mode 100644 index 0000000000..5c58d78fda --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGtTintTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGtTintTfloatLogicalFunction::EverGtTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverGtTintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGtTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGtTintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGtTintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGtTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGtTintTfloatLogicalFunction::getType() const { return NAME; } + +bool EverGtTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGtTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGtTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGtTintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtTintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGtTintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGtTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeTintTintLogicalFunction.cpp new file mode 100644 index 0000000000..079b5d64c0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLeTintTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLeTintTfloatLogicalFunction::EverLeTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverLeTintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLeTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLeTintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLeTintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLeTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLeTintTfloatLogicalFunction::getType() const { return NAME; } + +bool EverLeTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLeTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLeTintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeTintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLeTintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLeTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtTintTintLogicalFunction.cpp new file mode 100644 index 0000000000..39aa65da2f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLtTintTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLtTintTfloatLogicalFunction::EverLtTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverLtTintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLtTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLtTintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLtTintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLtTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLtTintTfloatLogicalFunction::getType() const { return NAME; } + +bool EverLtTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLtTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLtTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLtTintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtTintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLtTintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLtTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTintTintLogicalFunction.cpp new file mode 100644 index 0000000000..5a73940882 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTintTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTintTfloatLogicalFunction::EverNeTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeTintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverNeTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTintTfloatLogicalFunction::getType() const { return NAME; } + +bool EverNeTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverNeTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverNeTintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeTintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverNeTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTintTintPhysicalFunction.hpp new file mode 100644 index 0000000000..77d542711b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTintTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_eq_tint_tfloat`. + * + * Per-event ever_eq_tint_tfloat: tests if two single-instant tfloat values are ever equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverEqTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGeTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeTintTintPhysicalFunction.hpp new file mode 100644 index 0000000000..e0f449ef14 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGeTintTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ge_tint_tfloat`. + * + * Per-event ever_ge_tint_tfloat: tests if two single-instant tfloat values are ever greater or equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGeTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGeTintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGtTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtTintTintPhysicalFunction.hpp new file mode 100644 index 0000000000..6bed523848 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGtTintTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_gt_tint_tfloat`. + * + * Per-event ever_gt_tint_tfloat: tests if two single-instant tfloat values are ever greater than. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGtTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGtTintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLeTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeTintTintPhysicalFunction.hpp new file mode 100644 index 0000000000..15a53b5bdf --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLeTintTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_le_tint_tfloat`. + * + * Per-event ever_le_tint_tfloat: tests if two single-instant tfloat values are ever less or equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLeTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLeTintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLtTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtTintTintPhysicalFunction.hpp new file mode 100644 index 0000000000..b483fd4afc --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLtTintTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_lt_tint_tfloat`. + * + * Per-event ever_lt_tint_tfloat: tests if two single-instant tfloat values are ever less than. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLtTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLtTintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTintTintPhysicalFunction.hpp new file mode 100644 index 0000000000..070a0b888a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTintTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ne_tint_tfloat`. + * + * Per-event ever_ne_tint_tfloat: tests if two single-instant tfloat values are ever not equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverNeTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index b085495f7f..fe43ef7386 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -123,4 +123,10 @@ add_plugin(AlwaysGtTfloatTfloat PhysicalFunction nes-physical-operators AlwaysGt add_plugin(AlwaysLeTfloatTfloat PhysicalFunction nes-physical-operators AlwaysLeTfloatTfloatPhysicalFunction.cpp) add_plugin(AlwaysLtTfloatTfloat PhysicalFunction nes-physical-operators AlwaysLtTfloatTfloatPhysicalFunction.cpp) add_plugin(AlwaysNeTfloatTfloat PhysicalFunction nes-physical-operators AlwaysNeTfloatTfloatPhysicalFunction.cpp) +add_plugin(EverEqTintTint PhysicalFunction nes-physical-operators EverEqTintTintPhysicalFunction.cpp) +add_plugin(EverGeTintTint PhysicalFunction nes-physical-operators EverGeTintTintPhysicalFunction.cpp) +add_plugin(EverGtTintTint PhysicalFunction nes-physical-operators EverGtTintTintPhysicalFunction.cpp) +add_plugin(EverLeTintTint PhysicalFunction nes-physical-operators EverLeTintTintPhysicalFunction.cpp) +add_plugin(EverLtTintTint PhysicalFunction nes-physical-operators EverLtTintTintPhysicalFunction.cpp) +add_plugin(EverNeTintTint PhysicalFunction nes-physical-operators EverNeTintTintPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTintTintPhysicalFunction.cpp new file mode 100644 index 0000000000..caa3038238 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTintTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTintTintPhysicalFunction::EverEqTintTintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverEqTintTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_eq_tint_tint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTintTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqTintTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverEqTintTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGeTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeTintTintPhysicalFunction.cpp new file mode 100644 index 0000000000..7a82536015 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGeTintTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGeTintTintPhysicalFunction::EverGeTintTintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGeTintTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_ge_tint_tint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGeTintTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGeTintTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGeTintTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGtTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtTintTintPhysicalFunction.cpp new file mode 100644 index 0000000000..b5a76c9e8d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGtTintTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGtTintTintPhysicalFunction::EverGtTintTintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGtTintTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_gt_tint_tint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGtTintTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGtTintTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGtTintTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLeTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeTintTintPhysicalFunction.cpp new file mode 100644 index 0000000000..26f58ed26b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLeTintTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLeTintTintPhysicalFunction::EverLeTintTintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLeTintTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_le_tint_tint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLeTintTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLeTintTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLeTintTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLtTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtTintTintPhysicalFunction.cpp new file mode 100644 index 0000000000..584074e9f2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLtTintTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLtTintTintPhysicalFunction::EverLtTintTintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLtTintTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_lt_tint_tint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLtTintTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLtTintTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLtTintTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTintTintPhysicalFunction.cpp new file mode 100644 index 0000000000..168fc072c8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTintTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTintTintPhysicalFunction::EverNeTintTintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverNeTintTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_ne_tint_tint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTintTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeTintTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverNeTintTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 6eb4800e5c..b6b2681172 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -535,6 +535,12 @@ EVER_GT_TINT_INT: 'EVER_GT_TINT_INT' | 'ever_gt_tint_int'; EVER_LE_TINT_INT: 'EVER_LE_TINT_INT' | 'ever_le_tint_int'; EVER_LT_TINT_INT: 'EVER_LT_TINT_INT' | 'ever_lt_tint_int'; EVER_NE_TINT_INT: 'EVER_NE_TINT_INT' | 'ever_ne_tint_int'; +EVER_EQ_TINT_TINT: 'EVER_EQ_TINT_TINT' | 'ever_eq_tint_tint'; +EVER_GE_TINT_TINT: 'EVER_GE_TINT_TINT' | 'ever_ge_tint_tint'; +EVER_GT_TINT_TINT: 'EVER_GT_TINT_TINT' | 'ever_gt_tint_tint'; +EVER_LE_TINT_TINT: 'EVER_LE_TINT_TINT' | 'ever_le_tint_tint'; +EVER_LT_TINT_TINT: 'EVER_LT_TINT_TINT' | 'ever_lt_tint_tint'; +EVER_NE_TINT_TINT: 'EVER_NE_TINT_TINT' | 'ever_ne_tint_tint'; TGEO_AT_STBOX: 'TGEO_AT_STBOX' | 'tgeo_at_stbox'; ADD_BIGINT_TBIGINT: 'ADD_BIGINT_TBIGINT' | 'add_bigint_tbigint'; ADD_FLOAT_TFLOAT: 'ADD_FLOAT_TFLOAT' | 'add_float_tfloat'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 4055e8a63e..26d9aebd29 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -163,6 +163,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -3658,6 +3664,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: EVER_NE_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TINT_TINT */ + case AntlrSQLLexer::EVER_EQ_TINT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_TINT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GE_TINT_TINT */ + case AntlrSQLLexer::EVER_GE_TINT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GE_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGeTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GE_TINT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GT_TINT_TINT */ + case AntlrSQLLexer::EVER_GT_TINT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GT_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGtTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GT_TINT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LE_TINT_TINT */ + case AntlrSQLLexer::EVER_LE_TINT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LE_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLeTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LE_TINT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LT_TINT_TINT */ + case AntlrSQLLexer::EVER_LT_TINT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LT_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLtTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LT_TINT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_TINT_TINT */ + case AntlrSQLLexer::EVER_NE_TINT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_NE_TINT_TINT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TINT_INT */ case AntlrSQLLexer::ALWAYS_EQ_TINT_INT: { From fcb1af008fe7613deb637c9b4431e01a5d6ee844 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 09:53:49 +0200 Subject: [PATCH 28/86] feat(meos): add ALWAYS_EQ/GE/GT/LE/LT/NE_TINT_TINT NES operators (W70) --- .../Meos/AlwaysEqTintTintLogicalFunction.hpp | 54 ++++++ .../Meos/AlwaysGeTintTintLogicalFunction.hpp | 54 ++++++ .../Meos/AlwaysGtTintTintLogicalFunction.hpp | 54 ++++++ .../Meos/AlwaysLeTintTintLogicalFunction.hpp | 54 ++++++ .../Meos/AlwaysLtTintTintLogicalFunction.hpp | 54 ++++++ .../Meos/AlwaysNeTintTintLogicalFunction.hpp | 54 ++++++ .../Meos/AlwaysEqTintTintLogicalFunction.cpp | 105 ++++++++++ .../Meos/AlwaysGeTintTintLogicalFunction.cpp | 105 ++++++++++ .../Meos/AlwaysGtTintTintLogicalFunction.cpp | 105 ++++++++++ .../Meos/AlwaysLeTintTintLogicalFunction.cpp | 105 ++++++++++ .../Meos/AlwaysLtTintTintLogicalFunction.cpp | 105 ++++++++++ .../Meos/AlwaysNeTintTintLogicalFunction.cpp | 105 ++++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../Meos/AlwaysEqTintTintPhysicalFunction.hpp | 43 +++++ .../Meos/AlwaysGeTintTintPhysicalFunction.hpp | 43 +++++ .../Meos/AlwaysGtTintTintPhysicalFunction.hpp | 43 +++++ .../Meos/AlwaysLeTintTintPhysicalFunction.hpp | 43 +++++ .../Meos/AlwaysLtTintTintPhysicalFunction.hpp | 43 +++++ .../Meos/AlwaysNeTintTintPhysicalFunction.hpp | 43 +++++ .../Meos/AlwaysEqTintTintPhysicalFunction.cpp | 93 +++++++++ .../Meos/AlwaysGeTintTintPhysicalFunction.cpp | 93 +++++++++ .../Meos/AlwaysGtTintTintPhysicalFunction.cpp | 93 +++++++++ .../Meos/AlwaysLeTintTintPhysicalFunction.cpp | 93 +++++++++ .../Meos/AlwaysLtTintTintPhysicalFunction.cpp | 93 +++++++++ .../Meos/AlwaysNeTintTintPhysicalFunction.cpp | 93 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 180 ++++++++++++++++++ 28 files changed, 1969 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTintTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGeTintTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGtTintTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLeTintTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLtTintTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTintTintLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTintTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGeTintTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGtTintTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLeTintTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLtTintTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTintTintLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTintTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGeTintTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGtTintTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLeTintTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLtTintTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTintTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTintTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGeTintTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGtTintTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLeTintTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLtTintTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTintTintPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTintTintLogicalFunction.hpp new file mode 100644 index 0000000000..2e44a89f3a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTintTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_eq_tint_tfloat: tests if two single-instant tint values are always equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_eq_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysEqTintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTintTfloat"; + + AlwaysEqTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeTintTintLogicalFunction.hpp new file mode 100644 index 0000000000..feb35315bc --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeTintTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ge_tint_tfloat: tests if two single-instant tint values are always greater or equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ge_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGeTintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGeTintTfloat"; + + AlwaysGeTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtTintTintLogicalFunction.hpp new file mode 100644 index 0000000000..51e6feaca9 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtTintTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_gt_tint_tfloat: tests if two single-instant tint values are always greater than. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_gt_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGtTintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGtTintTfloat"; + + AlwaysGtTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeTintTintLogicalFunction.hpp new file mode 100644 index 0000000000..337148ee0e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeTintTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_le_tint_tfloat: tests if two single-instant tint values are always less or equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_le_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLeTintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLeTintTfloat"; + + AlwaysLeTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtTintTintLogicalFunction.hpp new file mode 100644 index 0000000000..0a9b5343c1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtTintTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_lt_tint_tfloat: tests if two single-instant tint values are always less than. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_lt_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLtTintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLtTintTfloat"; + + AlwaysLtTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTintTintLogicalFunction.hpp new file mode 100644 index 0000000000..73341c243e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTintTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ne_tint_tfloat: tests if two single-instant tint values are always not equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ne_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysNeTintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTintTfloat"; + + AlwaysNeTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTintTintLogicalFunction.cpp new file mode 100644 index 0000000000..4cdcffdd64 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTintTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTintTfloatLogicalFunction::AlwaysEqTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqTintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysEqTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTintTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysEqTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysEqTintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqTintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysEqTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeTintTintLogicalFunction.cpp new file mode 100644 index 0000000000..fb4f6f2a8e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeTintTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGeTintTfloatLogicalFunction::AlwaysGeTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGeTintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGeTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGeTintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGeTintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGeTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGeTintTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysGeTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGeTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGeTintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeTintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGeTintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGeTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtTintTintLogicalFunction.cpp new file mode 100644 index 0000000000..09c753625b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtTintTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGtTintTfloatLogicalFunction::AlwaysGtTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGtTintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGtTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGtTintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGtTintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGtTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGtTintTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysGtTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGtTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGtTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGtTintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtTintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGtTintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGtTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeTintTintLogicalFunction.cpp new file mode 100644 index 0000000000..356758b0cc --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeTintTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLeTintTfloatLogicalFunction::AlwaysLeTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLeTintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLeTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLeTintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLeTintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLeTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLeTintTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysLeTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLeTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLeTintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeTintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLeTintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLeTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtTintTintLogicalFunction.cpp new file mode 100644 index 0000000000..e88014e58e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtTintTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLtTintTfloatLogicalFunction::AlwaysLtTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLtTintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLtTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLtTintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLtTintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLtTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLtTintTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysLtTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLtTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLtTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLtTintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtTintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLtTintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLtTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTintTintLogicalFunction.cpp new file mode 100644 index 0000000000..83bcedc991 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTintTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTintTfloatLogicalFunction::AlwaysNeTintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeTintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysNeTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTintTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysNeTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysNeTintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeTintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysNeTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 0159b5ecb0..93056d8fe8 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -130,3 +130,9 @@ add_plugin(EverGtTintTint LogicalFunction nes-logical-operators EverGtTintTintLo add_plugin(EverLeTintTint LogicalFunction nes-logical-operators EverLeTintTintLogicalFunction.cpp) add_plugin(EverLtTintTint LogicalFunction nes-logical-operators EverLtTintTintLogicalFunction.cpp) add_plugin(EverNeTintTint LogicalFunction nes-logical-operators EverNeTintTintLogicalFunction.cpp) +add_plugin(AlwaysEqTintTint LogicalFunction nes-logical-operators AlwaysEqTintTintLogicalFunction.cpp) +add_plugin(AlwaysGeTintTint LogicalFunction nes-logical-operators AlwaysGeTintTintLogicalFunction.cpp) +add_plugin(AlwaysGtTintTint LogicalFunction nes-logical-operators AlwaysGtTintTintLogicalFunction.cpp) +add_plugin(AlwaysLeTintTint LogicalFunction nes-logical-operators AlwaysLeTintTintLogicalFunction.cpp) +add_plugin(AlwaysLtTintTint LogicalFunction nes-logical-operators AlwaysLtTintTintLogicalFunction.cpp) +add_plugin(AlwaysNeTintTint LogicalFunction nes-logical-operators AlwaysNeTintTintLogicalFunction.cpp) diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTintTintPhysicalFunction.hpp new file mode 100644 index 0000000000..de9dea6e9a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTintTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_eq_tint_tfloat`. + * + * Per-event always_eq_tint_tfloat: tests if two single-instant tfloat values are ever equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysEqTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeTintTintPhysicalFunction.hpp new file mode 100644 index 0000000000..7ec07a1a5e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeTintTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ge_tint_tfloat`. + * + * Per-event always_ge_tint_tfloat: tests if two single-instant tfloat values are ever greater or equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGeTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGeTintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtTintTintPhysicalFunction.hpp new file mode 100644 index 0000000000..ee47873039 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtTintTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_gt_tint_tfloat`. + * + * Per-event always_gt_tint_tfloat: tests if two single-instant tfloat values are ever greater than. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGtTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGtTintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeTintTintPhysicalFunction.hpp new file mode 100644 index 0000000000..38e8137ff1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeTintTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_le_tint_tfloat`. + * + * Per-event always_le_tint_tfloat: tests if two single-instant tfloat values are ever less or equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLeTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLeTintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtTintTintPhysicalFunction.hpp new file mode 100644 index 0000000000..ae9d97fd84 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtTintTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_lt_tint_tfloat`. + * + * Per-event always_lt_tint_tfloat: tests if two single-instant tfloat values are ever less than. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLtTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLtTintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTintTintPhysicalFunction.hpp new file mode 100644 index 0000000000..a2822cb82c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTintTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ne_tint_tfloat`. + * + * Per-event always_ne_tint_tfloat: tests if two single-instant tfloat values are ever not equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysNeTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTintTintPhysicalFunction.cpp new file mode 100644 index 0000000000..e1c238acdd --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTintTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTintTintPhysicalFunction::AlwaysEqTintTintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqTintTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_eq_tint_tint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTintTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqTintTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysEqTintTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeTintTintPhysicalFunction.cpp new file mode 100644 index 0000000000..13abe21605 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeTintTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGeTintTintPhysicalFunction::AlwaysGeTintTintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGeTintTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_ge_tint_tint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGeTintTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGeTintTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGeTintTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtTintTintPhysicalFunction.cpp new file mode 100644 index 0000000000..e9f1824a0c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtTintTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGtTintTintPhysicalFunction::AlwaysGtTintTintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGtTintTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_gt_tint_tint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGtTintTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGtTintTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGtTintTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeTintTintPhysicalFunction.cpp new file mode 100644 index 0000000000..974b4caaca --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeTintTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLeTintTintPhysicalFunction::AlwaysLeTintTintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLeTintTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_le_tint_tint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLeTintTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLeTintTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLeTintTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtTintTintPhysicalFunction.cpp new file mode 100644 index 0000000000..5649cde140 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtTintTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLtTintTintPhysicalFunction::AlwaysLtTintTintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLtTintTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_lt_tint_tint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLtTintTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLtTintTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLtTintTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTintTintPhysicalFunction.cpp new file mode 100644 index 0000000000..8ca2ce0681 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTintTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTintTintPhysicalFunction::AlwaysNeTintTintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeTintTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_ne_tint_tint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTintTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeTintTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysNeTintTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index fe43ef7386..74039cfadc 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -129,4 +129,10 @@ add_plugin(EverGtTintTint PhysicalFunction nes-physical-operators EverGtTintTint add_plugin(EverLeTintTint PhysicalFunction nes-physical-operators EverLeTintTintPhysicalFunction.cpp) add_plugin(EverLtTintTint PhysicalFunction nes-physical-operators EverLtTintTintPhysicalFunction.cpp) add_plugin(EverNeTintTint PhysicalFunction nes-physical-operators EverNeTintTintPhysicalFunction.cpp) +add_plugin(AlwaysEqTintTint PhysicalFunction nes-physical-operators AlwaysEqTintTintPhysicalFunction.cpp) +add_plugin(AlwaysGeTintTint PhysicalFunction nes-physical-operators AlwaysGeTintTintPhysicalFunction.cpp) +add_plugin(AlwaysGtTintTint PhysicalFunction nes-physical-operators AlwaysGtTintTintPhysicalFunction.cpp) +add_plugin(AlwaysLeTintTint PhysicalFunction nes-physical-operators AlwaysLeTintTintPhysicalFunction.cpp) +add_plugin(AlwaysLtTintTint PhysicalFunction nes-physical-operators AlwaysLtTintTintPhysicalFunction.cpp) +add_plugin(AlwaysNeTintTint PhysicalFunction nes-physical-operators AlwaysNeTintTintPhysicalFunction.cpp) endif() diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index b6b2681172..377064f091 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -510,6 +510,12 @@ ALWAYS_GT_TINT_INT: 'ALWAYS_GT_TINT_INT' | 'always_gt_tint_int'; ALWAYS_LE_TINT_INT: 'ALWAYS_LE_TINT_INT' | 'always_le_tint_int'; ALWAYS_LT_TINT_INT: 'ALWAYS_LT_TINT_INT' | 'always_lt_tint_int'; ALWAYS_NE_TINT_INT: 'ALWAYS_NE_TINT_INT' | 'always_ne_tint_int'; +ALWAYS_EQ_TINT_TINT: 'ALWAYS_EQ_TINT_TINT' | 'always_eq_tint_tint'; +ALWAYS_GE_TINT_TINT: 'ALWAYS_GE_TINT_TINT' | 'always_ge_tint_tint'; +ALWAYS_GT_TINT_TINT: 'ALWAYS_GT_TINT_TINT' | 'always_gt_tint_tint'; +ALWAYS_LE_TINT_TINT: 'ALWAYS_LE_TINT_TINT' | 'always_le_tint_tint'; +ALWAYS_LT_TINT_TINT: 'ALWAYS_LT_TINT_TINT' | 'always_lt_tint_tint'; +ALWAYS_NE_TINT_TINT: 'ALWAYS_NE_TINT_TINT' | 'always_ne_tint_tint'; EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; EVER_EQ_TBIGINT_BIGINT: 'EVER_EQ_TBIGINT_BIGINT' | 'ever_eq_tbigint_bigint'; EVER_GE_TBIGINT_BIGINT: 'EVER_GE_TBIGINT_BIGINT' | 'ever_ge_tbigint_bigint'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 26d9aebd29..88b06371e1 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -157,6 +157,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -4012,6 +4018,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: ALWAYS_NE_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TINT_TINT */ + case AntlrSQLLexer::ALWAYS_EQ_TINT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TINT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GE_TINT_TINT */ + case AntlrSQLLexer::ALWAYS_GE_TINT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GE_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGeTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GE_TINT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GT_TINT_TINT */ + case AntlrSQLLexer::ALWAYS_GT_TINT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GT_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGtTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GT_TINT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LE_TINT_TINT */ + case AntlrSQLLexer::ALWAYS_LE_TINT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LE_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLeTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LE_TINT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LT_TINT_TINT */ + case AntlrSQLLexer::ALWAYS_LT_TINT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LT_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLtTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LT_TINT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_TINT_TINT */ + case AntlrSQLLexer::ALWAYS_NE_TINT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_NE_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysNeTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TINT_TINT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TBIGINT_BIGINT */ case AntlrSQLLexer::ALWAYS_EQ_TBIGINT_BIGINT: { From b7e43752e883bced7479d779080aa51093ed52c1 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 09:55:19 +0200 Subject: [PATCH 29/86] feat(meos): add EVER_EQ/GE/GT/LE/LT/NE_TBIGINT_TBIGINT NES operators (W71) --- .../EverEqTbigintTbigintLogicalFunction.hpp | 54 ++++++ .../EverGeTbigintTbigintLogicalFunction.hpp | 54 ++++++ .../EverGtTbigintTbigintLogicalFunction.hpp | 54 ++++++ .../EverLeTbigintTbigintLogicalFunction.hpp | 54 ++++++ .../EverLtTbigintTbigintLogicalFunction.hpp | 54 ++++++ .../EverNeTbigintTbigintLogicalFunction.hpp | 54 ++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../EverEqTbigintTbigintLogicalFunction.cpp | 105 ++++++++++ .../EverGeTbigintTbigintLogicalFunction.cpp | 105 ++++++++++ .../EverGtTbigintTbigintLogicalFunction.cpp | 105 ++++++++++ .../EverLeTbigintTbigintLogicalFunction.cpp | 105 ++++++++++ .../EverLtTbigintTbigintLogicalFunction.cpp | 105 ++++++++++ .../EverNeTbigintTbigintLogicalFunction.cpp | 105 ++++++++++ .../EverEqTbigintTbigintPhysicalFunction.hpp | 43 +++++ .../EverGeTbigintTbigintPhysicalFunction.hpp | 43 +++++ .../EverGtTbigintTbigintPhysicalFunction.hpp | 43 +++++ .../EverLeTbigintTbigintPhysicalFunction.hpp | 43 +++++ .../EverLtTbigintTbigintPhysicalFunction.hpp | 43 +++++ .../EverNeTbigintTbigintPhysicalFunction.hpp | 43 +++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../EverEqTbigintTbigintPhysicalFunction.cpp | 93 +++++++++ .../EverGeTbigintTbigintPhysicalFunction.cpp | 93 +++++++++ .../EverGtTbigintTbigintPhysicalFunction.cpp | 93 +++++++++ .../EverLeTbigintTbigintPhysicalFunction.cpp | 93 +++++++++ .../EverLtTbigintTbigintPhysicalFunction.cpp | 93 +++++++++ .../EverNeTbigintTbigintPhysicalFunction.cpp | 93 +++++++++ nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 180 ++++++++++++++++++ 28 files changed, 1969 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTbigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGeTbigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGtTbigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLeTbigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLtTbigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTbigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTbigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGeTbigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGtTbigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLeTbigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLtTbigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTbigintTbigintLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTbigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..51cd3d91d3 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTbigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_eq_tbigint_tfloat: tests if two single-instant tbigint values are ever equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_eq_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverEqTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTbigintTfloat"; + + EverEqTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGeTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeTbigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..a69bc81c9e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGeTbigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ge_tbigint_tfloat: tests if two single-instant tbigint values are ever greater or equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ge_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGeTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGeTbigintTfloat"; + + EverGeTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGtTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtTbigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..cfba85ca24 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGtTbigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_gt_tbigint_tfloat: tests if two single-instant tbigint values are ever greater than. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_gt_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGtTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGtTbigintTfloat"; + + EverGtTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLeTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeTbigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..941fa3b879 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLeTbigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_le_tbigint_tfloat: tests if two single-instant tbigint values are ever less or equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_le_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLeTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLeTbigintTfloat"; + + EverLeTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLtTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtTbigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..a7069b03a1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLtTbigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_lt_tbigint_tfloat: tests if two single-instant tbigint values are ever less than. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_lt_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLtTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLtTbigintTfloat"; + + EverLtTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTbigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..db0619a55b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTbigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ne_tbigint_tfloat: tests if two single-instant tbigint values are ever not equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ne_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverNeTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTbigintTfloat"; + + EverNeTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 93056d8fe8..7b0c61ca48 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -136,3 +136,9 @@ add_plugin(AlwaysGtTintTint LogicalFunction nes-logical-operators AlwaysGtTintTi add_plugin(AlwaysLeTintTint LogicalFunction nes-logical-operators AlwaysLeTintTintLogicalFunction.cpp) add_plugin(AlwaysLtTintTint LogicalFunction nes-logical-operators AlwaysLtTintTintLogicalFunction.cpp) add_plugin(AlwaysNeTintTint LogicalFunction nes-logical-operators AlwaysNeTintTintLogicalFunction.cpp) +add_plugin(EverEqTbigintTbigint LogicalFunction nes-logical-operators EverEqTbigintTbigintLogicalFunction.cpp) +add_plugin(EverGeTbigintTbigint LogicalFunction nes-logical-operators EverGeTbigintTbigintLogicalFunction.cpp) +add_plugin(EverGtTbigintTbigint LogicalFunction nes-logical-operators EverGtTbigintTbigintLogicalFunction.cpp) +add_plugin(EverLeTbigintTbigint LogicalFunction nes-logical-operators EverLeTbigintTbigintLogicalFunction.cpp) +add_plugin(EverLtTbigintTbigint LogicalFunction nes-logical-operators EverLtTbigintTbigintLogicalFunction.cpp) +add_plugin(EverNeTbigintTbigint LogicalFunction nes-logical-operators EverNeTbigintTbigintLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTbigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..aff2bb3796 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTbigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTbigintTfloatLogicalFunction::EverEqTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqTbigintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTbigintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverEqTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTbigintTfloatLogicalFunction::getType() const { return NAME; } + +bool EverEqTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverEqTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverEqTbigintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTbigintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqTbigintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverEqTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeTbigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..124252845f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGeTbigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGeTbigintTfloatLogicalFunction::EverGeTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverGeTbigintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGeTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGeTbigintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGeTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGeTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGeTbigintTfloatLogicalFunction::getType() const { return NAME; } + +bool EverGeTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGeTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGeTbigintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeTbigintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGeTbigintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGeTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtTbigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..1c3161aadd --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGtTbigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGtTbigintTfloatLogicalFunction::EverGtTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverGtTbigintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGtTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGtTbigintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGtTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGtTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGtTbigintTfloatLogicalFunction::getType() const { return NAME; } + +bool EverGtTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGtTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGtTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGtTbigintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtTbigintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGtTbigintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGtTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeTbigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..6a0d2b51ad --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLeTbigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLeTbigintTfloatLogicalFunction::EverLeTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverLeTbigintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLeTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLeTbigintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLeTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLeTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLeTbigintTfloatLogicalFunction::getType() const { return NAME; } + +bool EverLeTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLeTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLeTbigintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeTbigintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLeTbigintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLeTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtTbigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..715a85cc22 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLtTbigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLtTbigintTfloatLogicalFunction::EverLtTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverLtTbigintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLtTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLtTbigintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLtTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLtTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLtTbigintTfloatLogicalFunction::getType() const { return NAME; } + +bool EverLtTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLtTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLtTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLtTbigintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtTbigintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLtTbigintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLtTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTbigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..c4bdbe9e42 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTbigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTbigintTfloatLogicalFunction::EverNeTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeTbigintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTbigintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverNeTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTbigintTfloatLogicalFunction::getType() const { return NAME; } + +bool EverNeTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverNeTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverNeTbigintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTbigintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeTbigintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverNeTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..feaa66970f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_eq_tbigint_tfloat`. + * + * Per-event ever_eq_tbigint_tfloat: tests if two single-instant tfloat values are ever equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverEqTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..c14497db81 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ge_tbigint_tfloat`. + * + * Per-event ever_ge_tbigint_tfloat: tests if two single-instant tfloat values are ever greater or equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGeTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGeTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..7137cd04c1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_gt_tbigint_tfloat`. + * + * Per-event ever_gt_tbigint_tfloat: tests if two single-instant tfloat values are ever greater than. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGtTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGtTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..f11bc3c16c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_le_tbigint_tfloat`. + * + * Per-event ever_le_tbigint_tfloat: tests if two single-instant tfloat values are ever less or equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLeTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLeTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..bb25e34d09 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_lt_tbigint_tfloat`. + * + * Per-event ever_lt_tbigint_tfloat: tests if two single-instant tfloat values are ever less than. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLtTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLtTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..406dd8b083 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ne_tbigint_tfloat`. + * + * Per-event ever_ne_tbigint_tfloat: tests if two single-instant tfloat values are ever not equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverNeTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 74039cfadc..1b06243f9f 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -135,4 +135,10 @@ add_plugin(AlwaysGtTintTint PhysicalFunction nes-physical-operators AlwaysGtTint add_plugin(AlwaysLeTintTint PhysicalFunction nes-physical-operators AlwaysLeTintTintPhysicalFunction.cpp) add_plugin(AlwaysLtTintTint PhysicalFunction nes-physical-operators AlwaysLtTintTintPhysicalFunction.cpp) add_plugin(AlwaysNeTintTint PhysicalFunction nes-physical-operators AlwaysNeTintTintPhysicalFunction.cpp) +add_plugin(EverEqTbigintTbigint PhysicalFunction nes-physical-operators EverEqTbigintTbigintPhysicalFunction.cpp) +add_plugin(EverGeTbigintTbigint PhysicalFunction nes-physical-operators EverGeTbigintTbigintPhysicalFunction.cpp) +add_plugin(EverGtTbigintTbigint PhysicalFunction nes-physical-operators EverGtTbigintTbigintPhysicalFunction.cpp) +add_plugin(EverLeTbigintTbigint PhysicalFunction nes-physical-operators EverLeTbigintTbigintPhysicalFunction.cpp) +add_plugin(EverLtTbigintTbigint PhysicalFunction nes-physical-operators EverLtTbigintTbigintPhysicalFunction.cpp) +add_plugin(EverNeTbigintTbigint PhysicalFunction nes-physical-operators EverNeTbigintTbigintPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..6c74c63431 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTbigintTbigintPhysicalFunction::EverEqTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverEqTbigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tbigint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbigint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_eq_tbigint_tbigint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTbigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqTbigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverEqTbigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..09f5309356 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGeTbigintTbigintPhysicalFunction::EverGeTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGeTbigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tbigint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbigint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_ge_tbigint_tbigint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGeTbigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGeTbigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGeTbigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..93d5cb0a0b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGtTbigintTbigintPhysicalFunction::EverGtTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGtTbigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tbigint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbigint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_gt_tbigint_tbigint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGtTbigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGtTbigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGtTbigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..f0492bd755 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLeTbigintTbigintPhysicalFunction::EverLeTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLeTbigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tbigint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbigint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_le_tbigint_tbigint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLeTbigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLeTbigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLeTbigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..31e6ac9ee5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLtTbigintTbigintPhysicalFunction::EverLtTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLtTbigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tbigint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbigint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_lt_tbigint_tbigint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLtTbigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLtTbigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLtTbigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..1709c60c40 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTbigintTbigintPhysicalFunction::EverNeTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverNeTbigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tbigint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbigint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_ne_tbigint_tbigint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTbigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeTbigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverNeTbigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 377064f091..f7183b330e 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -523,6 +523,12 @@ EVER_GT_TBIGINT_BIGINT: 'EVER_GT_TBIGINT_BIGINT' | 'ever_gt_tbigint_bigint'; EVER_LE_TBIGINT_BIGINT: 'EVER_LE_TBIGINT_BIGINT' | 'ever_le_tbigint_bigint'; EVER_LT_TBIGINT_BIGINT: 'EVER_LT_TBIGINT_BIGINT' | 'ever_lt_tbigint_bigint'; EVER_NE_TBIGINT_BIGINT: 'EVER_NE_TBIGINT_BIGINT' | 'ever_ne_tbigint_bigint'; +EVER_EQ_TBIGINT_TBIGINT: 'EVER_EQ_TBIGINT_TBIGINT' | 'ever_eq_tbigint_tbigint'; +EVER_GE_TBIGINT_TBIGINT: 'EVER_GE_TBIGINT_TBIGINT' | 'ever_ge_tbigint_tbigint'; +EVER_GT_TBIGINT_TBIGINT: 'EVER_GT_TBIGINT_TBIGINT' | 'ever_gt_tbigint_tbigint'; +EVER_LE_TBIGINT_TBIGINT: 'EVER_LE_TBIGINT_TBIGINT' | 'ever_le_tbigint_tbigint'; +EVER_LT_TBIGINT_TBIGINT: 'EVER_LT_TBIGINT_TBIGINT' | 'ever_lt_tbigint_tbigint'; +EVER_NE_TBIGINT_TBIGINT: 'EVER_NE_TBIGINT_TBIGINT' | 'ever_ne_tbigint_tbigint'; EVER_EQ_TFLOAT_FLOAT: 'EVER_EQ_TFLOAT_FLOAT' | 'ever_eq_tfloat_float'; EVER_GE_TFLOAT_FLOAT: 'EVER_GE_TFLOAT_FLOAT' | 'ever_ge_tfloat_float'; EVER_GT_TFLOAT_FLOAT: 'EVER_GT_TFLOAT_FLOAT' | 'ever_gt_tfloat_float'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 88b06371e1..fec51869a0 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -145,6 +145,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -3148,6 +3154,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: EVER_NE_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TBIGINT_TBIGINT */ + case AntlrSQLLexer::EVER_EQ_TBIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_TBIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqTbigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GE_TBIGINT_TBIGINT */ + case AntlrSQLLexer::EVER_GE_TBIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GE_TBIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGeTbigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GE_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GT_TBIGINT_TBIGINT */ + case AntlrSQLLexer::EVER_GT_TBIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GT_TBIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGtTbigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GT_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LE_TBIGINT_TBIGINT */ + case AntlrSQLLexer::EVER_LE_TBIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LE_TBIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLeTbigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LE_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LT_TBIGINT_TBIGINT */ + case AntlrSQLLexer::EVER_LT_TBIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LT_TBIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLtTbigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LT_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_TBIGINT_TBIGINT */ + case AntlrSQLLexer::EVER_NE_TBIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_TBIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeTbigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_NE_TBIGINT_TBIGINT */ /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::EVER_EQ_TFLOAT_FLOAT: { From e02d16111f59a6bd45fad534ec3890351e71610a Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 09:56:52 +0200 Subject: [PATCH 30/86] feat(meos): add ALWAYS_EQ/GE/GT/LE/LT/NE_TBIGINT_TBIGINT NES operators (W72) --- .../AlwaysEqTbigintTbigintLogicalFunction.hpp | 54 ++++++ .../AlwaysGeTbigintTbigintLogicalFunction.hpp | 54 ++++++ .../AlwaysGtTbigintTbigintLogicalFunction.hpp | 54 ++++++ .../AlwaysLeTbigintTbigintLogicalFunction.hpp | 54 ++++++ .../AlwaysLtTbigintTbigintLogicalFunction.hpp | 54 ++++++ .../AlwaysNeTbigintTbigintLogicalFunction.hpp | 54 ++++++ .../AlwaysEqTbigintTbigintLogicalFunction.cpp | 105 ++++++++++ .../AlwaysGeTbigintTbigintLogicalFunction.cpp | 105 ++++++++++ .../AlwaysGtTbigintTbigintLogicalFunction.cpp | 105 ++++++++++ .../AlwaysLeTbigintTbigintLogicalFunction.cpp | 105 ++++++++++ .../AlwaysLtTbigintTbigintLogicalFunction.cpp | 105 ++++++++++ .../AlwaysNeTbigintTbigintLogicalFunction.cpp | 105 ++++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + ...AlwaysEqTbigintTbigintPhysicalFunction.hpp | 43 +++++ ...AlwaysGeTbigintTbigintPhysicalFunction.hpp | 43 +++++ ...AlwaysGtTbigintTbigintPhysicalFunction.hpp | 43 +++++ ...AlwaysLeTbigintTbigintPhysicalFunction.hpp | 43 +++++ ...AlwaysLtTbigintTbigintPhysicalFunction.hpp | 43 +++++ ...AlwaysNeTbigintTbigintPhysicalFunction.hpp | 43 +++++ ...AlwaysEqTbigintTbigintPhysicalFunction.cpp | 93 +++++++++ ...AlwaysGeTbigintTbigintPhysicalFunction.cpp | 93 +++++++++ ...AlwaysGtTbigintTbigintPhysicalFunction.cpp | 93 +++++++++ ...AlwaysLeTbigintTbigintPhysicalFunction.cpp | 93 +++++++++ ...AlwaysLtTbigintTbigintPhysicalFunction.cpp | 93 +++++++++ ...AlwaysNeTbigintTbigintPhysicalFunction.cpp | 93 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 180 ++++++++++++++++++ 28 files changed, 1969 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..46b63578c9 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_eq_tbigint_tfloat: tests if two single-instant tbigint values are always equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_eq_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysEqTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTbigintTfloat"; + + AlwaysEqTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..37f9d8e151 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ge_tbigint_tfloat: tests if two single-instant tbigint values are always greater or equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ge_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGeTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGeTbigintTfloat"; + + AlwaysGeTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..48addeef95 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_gt_tbigint_tfloat: tests if two single-instant tbigint values are always greater than. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_gt_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGtTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGtTbigintTfloat"; + + AlwaysGtTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..6c5c2998b6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_le_tbigint_tfloat: tests if two single-instant tbigint values are always less or equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_le_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLeTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLeTbigintTfloat"; + + AlwaysLeTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..bef92d195e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_lt_tbigint_tfloat: tests if two single-instant tbigint values are always less than. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_lt_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLtTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLtTbigintTfloat"; + + AlwaysLtTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..47801d4c53 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ne_tbigint_tfloat: tests if two single-instant tbigint values are always not equal. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ne_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), + * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysNeTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTbigintTfloat"; + + AlwaysNeTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..7ca05704e4 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTbigintTfloatLogicalFunction::AlwaysEqTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqTbigintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTbigintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysEqTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTbigintTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysEqTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysEqTbigintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTbigintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqTbigintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysEqTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..b97bd4c734 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGeTbigintTfloatLogicalFunction::AlwaysGeTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGeTbigintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGeTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGeTbigintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGeTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGeTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGeTbigintTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysGeTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGeTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGeTbigintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeTbigintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGeTbigintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGeTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..794de5ab88 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGtTbigintTfloatLogicalFunction::AlwaysGtTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGtTbigintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGtTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGtTbigintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGtTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGtTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGtTbigintTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysGtTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGtTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGtTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGtTbigintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtTbigintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGtTbigintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGtTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..33641ce8e0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLeTbigintTfloatLogicalFunction::AlwaysLeTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLeTbigintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLeTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLeTbigintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLeTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLeTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLeTbigintTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysLeTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLeTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLeTbigintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeTbigintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLeTbigintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLeTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..38e012aebc --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLtTbigintTfloatLogicalFunction::AlwaysLtTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLtTbigintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLtTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLtTbigintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLtTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLtTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLtTbigintTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysLtTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLtTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLtTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLtTbigintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtTbigintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLtTbigintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLtTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..9a9eda9b8d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTbigintTfloatLogicalFunction::AlwaysNeTbigintTfloatLogicalFunction(LogicalFunction value1, + LogicalFunction value2, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeTbigintTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTbigintTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysNeTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTbigintTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysNeTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysNeTbigintTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTbigintTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeTbigintTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysNeTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 7b0c61ca48..ff6190bffd 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -142,3 +142,9 @@ add_plugin(EverGtTbigintTbigint LogicalFunction nes-logical-operators EverGtTbig add_plugin(EverLeTbigintTbigint LogicalFunction nes-logical-operators EverLeTbigintTbigintLogicalFunction.cpp) add_plugin(EverLtTbigintTbigint LogicalFunction nes-logical-operators EverLtTbigintTbigintLogicalFunction.cpp) add_plugin(EverNeTbigintTbigint LogicalFunction nes-logical-operators EverNeTbigintTbigintLogicalFunction.cpp) +add_plugin(AlwaysEqTbigintTbigint LogicalFunction nes-logical-operators AlwaysEqTbigintTbigintLogicalFunction.cpp) +add_plugin(AlwaysGeTbigintTbigint LogicalFunction nes-logical-operators AlwaysGeTbigintTbigintLogicalFunction.cpp) +add_plugin(AlwaysGtTbigintTbigint LogicalFunction nes-logical-operators AlwaysGtTbigintTbigintLogicalFunction.cpp) +add_plugin(AlwaysLeTbigintTbigint LogicalFunction nes-logical-operators AlwaysLeTbigintTbigintLogicalFunction.cpp) +add_plugin(AlwaysLtTbigintTbigint LogicalFunction nes-logical-operators AlwaysLtTbigintTbigintLogicalFunction.cpp) +add_plugin(AlwaysNeTbigintTbigint LogicalFunction nes-logical-operators AlwaysNeTbigintTbigintLogicalFunction.cpp) diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..d03da809cf --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_eq_tbigint_tfloat`. + * + * Per-event always_eq_tbigint_tfloat: tests if two single-instant tfloat values are ever equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysEqTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..8d166e1d18 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ge_tbigint_tfloat`. + * + * Per-event always_ge_tbigint_tfloat: tests if two single-instant tfloat values are ever greater or equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGeTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGeTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..85322c8557 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_gt_tbigint_tfloat`. + * + * Per-event always_gt_tbigint_tfloat: tests if two single-instant tfloat values are ever greater than. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGtTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGtTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..bbaf3b2281 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_le_tbigint_tfloat`. + * + * Per-event always_le_tbigint_tfloat: tests if two single-instant tfloat values are ever less or equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLeTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLeTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..ce560fd1c2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_lt_tbigint_tfloat`. + * + * Per-event always_lt_tbigint_tfloat: tests if two single-instant tfloat values are ever less than. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLtTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLtTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..acf3065538 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ne_tbigint_tfloat`. + * + * Per-event always_ne_tbigint_tfloat: tests if two single-instant tfloat values are ever not equal. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysNeTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..bf44057630 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTbigintTbigintPhysicalFunction::AlwaysEqTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqTbigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tbigint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbigint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_eq_tbigint_tbigint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTbigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqTbigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysEqTbigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..f810dcceb8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGeTbigintTbigintPhysicalFunction::AlwaysGeTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGeTbigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tbigint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbigint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_ge_tbigint_tbigint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGeTbigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGeTbigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGeTbigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..06b7e7ee23 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGtTbigintTbigintPhysicalFunction::AlwaysGtTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGtTbigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tbigint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbigint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_gt_tbigint_tbigint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGtTbigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGtTbigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGtTbigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..d2cb50c242 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLeTbigintTbigintPhysicalFunction::AlwaysLeTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLeTbigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tbigint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbigint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_le_tbigint_tbigint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLeTbigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLeTbigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLeTbigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..6c704c5f0b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLtTbigintTbigintPhysicalFunction::AlwaysLtTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLtTbigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tbigint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbigint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_lt_tbigint_tbigint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLtTbigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLtTbigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLtTbigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..1ea159194d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTbigintTbigintPhysicalFunction::AlwaysNeTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeTbigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", static_cast(v1), ts_str); + std::string wkt2 = fmt::format("{}@{}", static_cast(v2), ts_str); + Temporal* temp1 = tbigint_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbigint_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_ne_tbigint_tbigint(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTbigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeTbigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysNeTbigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 1b06243f9f..1bd1c2eae2 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -141,4 +141,10 @@ add_plugin(EverGtTbigintTbigint PhysicalFunction nes-physical-operators EverGtTb add_plugin(EverLeTbigintTbigint PhysicalFunction nes-physical-operators EverLeTbigintTbigintPhysicalFunction.cpp) add_plugin(EverLtTbigintTbigint PhysicalFunction nes-physical-operators EverLtTbigintTbigintPhysicalFunction.cpp) add_plugin(EverNeTbigintTbigint PhysicalFunction nes-physical-operators EverNeTbigintTbigintPhysicalFunction.cpp) +add_plugin(AlwaysEqTbigintTbigint PhysicalFunction nes-physical-operators AlwaysEqTbigintTbigintPhysicalFunction.cpp) +add_plugin(AlwaysGeTbigintTbigint PhysicalFunction nes-physical-operators AlwaysGeTbigintTbigintPhysicalFunction.cpp) +add_plugin(AlwaysGtTbigintTbigint PhysicalFunction nes-physical-operators AlwaysGtTbigintTbigintPhysicalFunction.cpp) +add_plugin(AlwaysLeTbigintTbigint PhysicalFunction nes-physical-operators AlwaysLeTbigintTbigintPhysicalFunction.cpp) +add_plugin(AlwaysLtTbigintTbigint PhysicalFunction nes-physical-operators AlwaysLtTbigintTbigintPhysicalFunction.cpp) +add_plugin(AlwaysNeTbigintTbigint PhysicalFunction nes-physical-operators AlwaysNeTbigintTbigintPhysicalFunction.cpp) endif() diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index f7183b330e..e445bb7205 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -492,6 +492,12 @@ ALWAYS_GT_TBIGINT_BIGINT: 'ALWAYS_GT_TBIGINT_BIGINT' | 'always_gt_tbigint_bigint ALWAYS_LE_TBIGINT_BIGINT: 'ALWAYS_LE_TBIGINT_BIGINT' | 'always_le_tbigint_bigint'; ALWAYS_LT_TBIGINT_BIGINT: 'ALWAYS_LT_TBIGINT_BIGINT' | 'always_lt_tbigint_bigint'; ALWAYS_NE_TBIGINT_BIGINT: 'ALWAYS_NE_TBIGINT_BIGINT' | 'always_ne_tbigint_bigint'; +ALWAYS_EQ_TBIGINT_TBIGINT: 'ALWAYS_EQ_TBIGINT_TBIGINT' | 'always_eq_tbigint_tbigint'; +ALWAYS_GE_TBIGINT_TBIGINT: 'ALWAYS_GE_TBIGINT_TBIGINT' | 'always_ge_tbigint_tbigint'; +ALWAYS_GT_TBIGINT_TBIGINT: 'ALWAYS_GT_TBIGINT_TBIGINT' | 'always_gt_tbigint_tbigint'; +ALWAYS_LE_TBIGINT_TBIGINT: 'ALWAYS_LE_TBIGINT_TBIGINT' | 'always_le_tbigint_tbigint'; +ALWAYS_LT_TBIGINT_TBIGINT: 'ALWAYS_LT_TBIGINT_TBIGINT' | 'always_lt_tbigint_tbigint'; +ALWAYS_NE_TBIGINT_TBIGINT: 'ALWAYS_NE_TBIGINT_TBIGINT' | 'always_ne_tbigint_tbigint'; ALWAYS_EQ_TFLOAT_FLOAT: 'ALWAYS_EQ_TFLOAT_FLOAT' | 'always_eq_tfloat_float'; ALWAYS_GE_TFLOAT_FLOAT: 'ALWAYS_GE_TFLOAT_FLOAT' | 'always_ge_tfloat_float'; ALWAYS_GT_TFLOAT_FLOAT: 'ALWAYS_GT_TFLOAT_FLOAT' | 'always_gt_tfloat_float'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index fec51869a0..1c1b52c852 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -139,6 +139,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -4546,6 +4552,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: ALWAYS_NE_TBIGINT_BIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TBIGINT_TBIGINT */ + case AntlrSQLLexer::ALWAYS_EQ_TBIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_TBIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqTbigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GE_TBIGINT_TBIGINT */ + case AntlrSQLLexer::ALWAYS_GE_TBIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GE_TBIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGeTbigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GE_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GT_TBIGINT_TBIGINT */ + case AntlrSQLLexer::ALWAYS_GT_TBIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GT_TBIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGtTbigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GT_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LE_TBIGINT_TBIGINT */ + case AntlrSQLLexer::ALWAYS_LE_TBIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LE_TBIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLeTbigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LE_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LT_TBIGINT_TBIGINT */ + case AntlrSQLLexer::ALWAYS_LT_TBIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LT_TBIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLtTbigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LT_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_TBIGINT_TBIGINT */ + case AntlrSQLLexer::ALWAYS_NE_TBIGINT_TBIGINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_NE_TBIGINT_TBIGINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysNeTbigintTbigintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TBIGINT_TBIGINT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 6e3d9c334cb1632fe72956a991c8ea27cf01e58d Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 10:14:02 +0200 Subject: [PATCH 31/86] feat(meos): add EVER/ALWAYS_EQ/GE/GT/LE/LT/NE reversed scalar NES operators (W73-W78) Adds 36 per-event NES operators for the reversed-argument scalar comparisons: EVER_{EQ,GE,GT,LE,LT,NE}_{FLOAT_TFLOAT,INT_TINT,BIGINT_TBIGINT} (W73/W75/W77) and ALWAYS_{EQ,GE,GT,LE,LT,NE}_{FLOAT_TFLOAT,INT_TINT,BIGINT_TBIGINT} (W74/W76/W78). Each 3-arg operator takes (scalar, temporal_value, ts:UINT64), builds a single-instant temporal from args 1-2, and calls the MEOS reversed-form function (e.g. ever_eq_float_tfloat(double, Temporal*)) with the scalar as the first argument. Wired across all five locations: logical/physical CMakeLists, AntlrSQL.g4 functionName rule and lexer section, and AntlrSQLQueryPlanCreator.cpp includes and case blocks. --- .../AlwaysEqBigintTbigintLogicalFunction.hpp | 54 + .../AlwaysEqFloatTfloatLogicalFunction.hpp | 54 + .../Meos/AlwaysEqIntTintLogicalFunction.hpp | 54 + .../AlwaysGeBigintTbigintLogicalFunction.hpp | 54 + .../AlwaysGeFloatTfloatLogicalFunction.hpp | 54 + .../Meos/AlwaysGeIntTintLogicalFunction.hpp | 54 + .../AlwaysGtBigintTbigintLogicalFunction.hpp | 54 + .../AlwaysGtFloatTfloatLogicalFunction.hpp | 54 + .../Meos/AlwaysGtIntTintLogicalFunction.hpp | 54 + .../AlwaysLeBigintTbigintLogicalFunction.hpp | 54 + .../AlwaysLeFloatTfloatLogicalFunction.hpp | 54 + .../Meos/AlwaysLeIntTintLogicalFunction.hpp | 54 + .../AlwaysLtBigintTbigintLogicalFunction.hpp | 54 + .../AlwaysLtFloatTfloatLogicalFunction.hpp | 54 + .../Meos/AlwaysLtIntTintLogicalFunction.hpp | 54 + .../AlwaysNeBigintTbigintLogicalFunction.hpp | 54 + .../AlwaysNeFloatTfloatLogicalFunction.hpp | 54 + .../Meos/AlwaysNeIntTintLogicalFunction.hpp | 54 + .../EverEqBigintTbigintLogicalFunction.hpp | 54 + .../Meos/EverEqFloatTfloatLogicalFunction.hpp | 54 + .../Meos/EverEqIntTintLogicalFunction.hpp | 54 + .../EverGeBigintTbigintLogicalFunction.hpp | 54 + .../Meos/EverGeFloatTfloatLogicalFunction.hpp | 54 + .../Meos/EverGeIntTintLogicalFunction.hpp | 54 + .../EverGtBigintTbigintLogicalFunction.hpp | 54 + .../Meos/EverGtFloatTfloatLogicalFunction.hpp | 54 + .../Meos/EverGtIntTintLogicalFunction.hpp | 54 + .../EverLeBigintTbigintLogicalFunction.hpp | 54 + .../Meos/EverLeFloatTfloatLogicalFunction.hpp | 54 + .../Meos/EverLeIntTintLogicalFunction.hpp | 54 + .../EverLtBigintTbigintLogicalFunction.hpp | 54 + .../Meos/EverLtFloatTfloatLogicalFunction.hpp | 54 + .../Meos/EverLtIntTintLogicalFunction.hpp | 54 + .../EverNeBigintTbigintLogicalFunction.hpp | 54 + .../Meos/EverNeFloatTfloatLogicalFunction.hpp | 54 + .../Meos/EverNeIntTintLogicalFunction.hpp | 54 + .../AlwaysEqBigintTbigintLogicalFunction.cpp | 105 ++ .../AlwaysEqFloatTfloatLogicalFunction.cpp | 105 ++ .../Meos/AlwaysEqIntTintLogicalFunction.cpp | 105 ++ .../AlwaysGeBigintTbigintLogicalFunction.cpp | 105 ++ .../AlwaysGeFloatTfloatLogicalFunction.cpp | 105 ++ .../Meos/AlwaysGeIntTintLogicalFunction.cpp | 105 ++ .../AlwaysGtBigintTbigintLogicalFunction.cpp | 105 ++ .../AlwaysGtFloatTfloatLogicalFunction.cpp | 105 ++ .../Meos/AlwaysGtIntTintLogicalFunction.cpp | 105 ++ .../AlwaysLeBigintTbigintLogicalFunction.cpp | 105 ++ .../AlwaysLeFloatTfloatLogicalFunction.cpp | 105 ++ .../Meos/AlwaysLeIntTintLogicalFunction.cpp | 105 ++ .../AlwaysLtBigintTbigintLogicalFunction.cpp | 105 ++ .../AlwaysLtFloatTfloatLogicalFunction.cpp | 105 ++ .../Meos/AlwaysLtIntTintLogicalFunction.cpp | 105 ++ .../AlwaysNeBigintTbigintLogicalFunction.cpp | 105 ++ .../AlwaysNeFloatTfloatLogicalFunction.cpp | 105 ++ .../Meos/AlwaysNeIntTintLogicalFunction.cpp | 105 ++ .../src/Functions/Meos/CMakeLists.txt | 36 + .../EverEqBigintTbigintLogicalFunction.cpp | 105 ++ .../Meos/EverEqFloatTfloatLogicalFunction.cpp | 105 ++ .../Meos/EverEqIntTintLogicalFunction.cpp | 105 ++ .../EverGeBigintTbigintLogicalFunction.cpp | 105 ++ .../Meos/EverGeFloatTfloatLogicalFunction.cpp | 105 ++ .../Meos/EverGeIntTintLogicalFunction.cpp | 105 ++ .../EverGtBigintTbigintLogicalFunction.cpp | 105 ++ .../Meos/EverGtFloatTfloatLogicalFunction.cpp | 105 ++ .../Meos/EverGtIntTintLogicalFunction.cpp | 105 ++ .../EverLeBigintTbigintLogicalFunction.cpp | 105 ++ .../Meos/EverLeFloatTfloatLogicalFunction.cpp | 105 ++ .../Meos/EverLeIntTintLogicalFunction.cpp | 105 ++ .../EverLtBigintTbigintLogicalFunction.cpp | 105 ++ .../Meos/EverLtFloatTfloatLogicalFunction.cpp | 105 ++ .../Meos/EverLtIntTintLogicalFunction.cpp | 105 ++ .../EverNeBigintTbigintLogicalFunction.cpp | 105 ++ .../Meos/EverNeFloatTfloatLogicalFunction.cpp | 105 ++ .../Meos/EverNeIntTintLogicalFunction.cpp | 105 ++ .../AlwaysEqBigintTbigintPhysicalFunction.hpp | 43 + .../AlwaysEqFloatTfloatPhysicalFunction.hpp | 43 + .../Meos/AlwaysEqIntTintPhysicalFunction.hpp | 43 + .../AlwaysGeBigintTbigintPhysicalFunction.hpp | 43 + .../AlwaysGeFloatTfloatPhysicalFunction.hpp | 43 + .../Meos/AlwaysGeIntTintPhysicalFunction.hpp | 43 + .../AlwaysGtBigintTbigintPhysicalFunction.hpp | 43 + .../AlwaysGtFloatTfloatPhysicalFunction.hpp | 43 + .../Meos/AlwaysGtIntTintPhysicalFunction.hpp | 43 + .../AlwaysLeBigintTbigintPhysicalFunction.hpp | 43 + .../AlwaysLeFloatTfloatPhysicalFunction.hpp | 43 + .../Meos/AlwaysLeIntTintPhysicalFunction.hpp | 43 + .../AlwaysLtBigintTbigintPhysicalFunction.hpp | 43 + .../AlwaysLtFloatTfloatPhysicalFunction.hpp | 43 + .../Meos/AlwaysLtIntTintPhysicalFunction.hpp | 43 + .../AlwaysNeBigintTbigintPhysicalFunction.hpp | 43 + .../AlwaysNeFloatTfloatPhysicalFunction.hpp | 43 + .../Meos/AlwaysNeIntTintPhysicalFunction.hpp | 43 + .../EverEqBigintTbigintPhysicalFunction.hpp | 43 + .../EverEqFloatTfloatPhysicalFunction.hpp | 43 + .../Meos/EverEqIntTintPhysicalFunction.hpp | 43 + .../EverGeBigintTbigintPhysicalFunction.hpp | 43 + .../EverGeFloatTfloatPhysicalFunction.hpp | 43 + .../Meos/EverGeIntTintPhysicalFunction.hpp | 43 + .../EverGtBigintTbigintPhysicalFunction.hpp | 43 + .../EverGtFloatTfloatPhysicalFunction.hpp | 43 + .../Meos/EverGtIntTintPhysicalFunction.hpp | 43 + .../EverLeBigintTbigintPhysicalFunction.hpp | 43 + .../EverLeFloatTfloatPhysicalFunction.hpp | 43 + .../Meos/EverLeIntTintPhysicalFunction.hpp | 43 + .../EverLtBigintTbigintPhysicalFunction.hpp | 43 + .../EverLtFloatTfloatPhysicalFunction.hpp | 43 + .../Meos/EverLtIntTintPhysicalFunction.hpp | 43 + .../EverNeBigintTbigintPhysicalFunction.hpp | 43 + .../EverNeFloatTfloatPhysicalFunction.hpp | 43 + .../Meos/EverNeIntTintPhysicalFunction.hpp | 43 + .../AlwaysEqBigintTbigintPhysicalFunction.cpp | 89 ++ .../AlwaysEqFloatTfloatPhysicalFunction.cpp | 89 ++ .../Meos/AlwaysEqIntTintPhysicalFunction.cpp | 89 ++ .../AlwaysGeBigintTbigintPhysicalFunction.cpp | 89 ++ .../AlwaysGeFloatTfloatPhysicalFunction.cpp | 89 ++ .../Meos/AlwaysGeIntTintPhysicalFunction.cpp | 89 ++ .../AlwaysGtBigintTbigintPhysicalFunction.cpp | 89 ++ .../AlwaysGtFloatTfloatPhysicalFunction.cpp | 89 ++ .../Meos/AlwaysGtIntTintPhysicalFunction.cpp | 89 ++ .../AlwaysLeBigintTbigintPhysicalFunction.cpp | 89 ++ .../AlwaysLeFloatTfloatPhysicalFunction.cpp | 89 ++ .../Meos/AlwaysLeIntTintPhysicalFunction.cpp | 89 ++ .../AlwaysLtBigintTbigintPhysicalFunction.cpp | 89 ++ .../AlwaysLtFloatTfloatPhysicalFunction.cpp | 89 ++ .../Meos/AlwaysLtIntTintPhysicalFunction.cpp | 89 ++ .../AlwaysNeBigintTbigintPhysicalFunction.cpp | 89 ++ .../AlwaysNeFloatTfloatPhysicalFunction.cpp | 89 ++ .../Meos/AlwaysNeIntTintPhysicalFunction.cpp | 89 ++ .../src/Functions/Meos/CMakeLists.txt | 36 + .../EverEqBigintTbigintPhysicalFunction.cpp | 89 ++ .../EverEqFloatTfloatPhysicalFunction.cpp | 89 ++ .../Meos/EverEqIntTintPhysicalFunction.cpp | 89 ++ .../EverGeBigintTbigintPhysicalFunction.cpp | 89 ++ .../EverGeFloatTfloatPhysicalFunction.cpp | 89 ++ .../Meos/EverGeIntTintPhysicalFunction.cpp | 89 ++ .../EverGtBigintTbigintPhysicalFunction.cpp | 89 ++ .../EverGtFloatTfloatPhysicalFunction.cpp | 89 ++ .../Meos/EverGtIntTintPhysicalFunction.cpp | 89 ++ .../EverLeBigintTbigintPhysicalFunction.cpp | 89 ++ .../EverLeFloatTfloatPhysicalFunction.cpp | 89 ++ .../Meos/EverLeIntTintPhysicalFunction.cpp | 89 ++ .../EverLtBigintTbigintPhysicalFunction.cpp | 89 ++ .../EverLtFloatTfloatPhysicalFunction.cpp | 89 ++ .../Meos/EverLtIntTintPhysicalFunction.cpp | 89 ++ .../EverNeBigintTbigintPhysicalFunction.cpp | 89 ++ .../EverNeFloatTfloatPhysicalFunction.cpp | 89 ++ .../Meos/EverNeIntTintPhysicalFunction.cpp | 89 ++ nes-sql-parser/AntlrSQL.g4 | 38 +- .../src/AntlrSQLQueryPlanCreator.cpp | 1110 ++++++++++++++++- 148 files changed, 11680 insertions(+), 16 deletions(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGeBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGeFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGeIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGtBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGtFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGtIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLeBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLeFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLeIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLtBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLtFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLtIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGeBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGeFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGeIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGtBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGtFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGtIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLeBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLeFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLeIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLtBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLtFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLtIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeBigintTbigintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGeBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGeFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGeIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGtBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGtFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGtIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLeBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLeFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLeIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLtBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLtFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLtIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGeBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGeFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGeIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGtBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGtFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGtIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLeBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLeFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLeIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLtBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLtFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLtIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeBigintTbigintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeIntTintLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGeBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGeFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGeIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGtBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGtFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGtIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLeBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLeFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLeIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLtBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLtFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLtIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGeBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGeFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGeIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGtBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGtFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGtIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLeBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLeFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLeIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLtBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLtFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLtIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeBigintTbigintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGeBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGeFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGeIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGtBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGtFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGtIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLeBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLeFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLeIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLtBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLtFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLtIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGeBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGeFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGeIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGtBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGtFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGtIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLeBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLeFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLeIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLtBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLtFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLtIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeBigintTbigintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeIntTintPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..c913c19a88 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_eq_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_eq_bigint_tbigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysEqBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqBigintTbigint"; + + AlwaysEqBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..04d802d4a6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_eq_float_tfloat: tests if a scalar is ever eq to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_eq_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysEqFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqFloatTfloat"; + + AlwaysEqFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..4dce2e23c9 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_eq_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_eq_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysEqIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqIntTint"; + + AlwaysEqIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..50be02fa7d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ge_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ge_bigint_tbigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGeBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGeBigintTbigint"; + + AlwaysGeBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..d4487cbe9d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ge_float_tfloat: tests if a scalar is ever ge to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ge_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGeFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGeFloatTfloat"; + + AlwaysGeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..b235a0d3e9 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ge_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ge_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGeIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGeIntTint"; + + AlwaysGeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..8a13220e59 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_gt_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_gt_bigint_tbigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGtBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGtBigintTbigint"; + + AlwaysGtBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..486b70ae14 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_gt_float_tfloat: tests if a scalar is ever gt to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_gt_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGtFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGtFloatTfloat"; + + AlwaysGtFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..889d38e00d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_gt_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_gt_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGtIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGtIntTint"; + + AlwaysGtIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..de67cd5e6b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_le_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_le_bigint_tbigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLeBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLeBigintTbigint"; + + AlwaysLeBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..8eb944e4e6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_le_float_tfloat: tests if a scalar is ever le to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_le_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLeFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLeFloatTfloat"; + + AlwaysLeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..9f58bb96b8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_le_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_le_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLeIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLeIntTint"; + + AlwaysLeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..890638fcd1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_lt_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_lt_bigint_tbigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLtBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLtBigintTbigint"; + + AlwaysLtBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..295b78e104 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_lt_float_tfloat: tests if a scalar is ever lt to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_lt_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLtFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLtFloatTfloat"; + + AlwaysLtFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..df9002deea --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_lt_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_lt_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLtIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLtIntTint"; + + AlwaysLtIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..d869e96888 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ne_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ne_bigint_tbigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysNeBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeBigintTbigint"; + + AlwaysNeBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..320d55e6fe --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ne_float_tfloat: tests if a scalar is ever ne to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ne_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysNeFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeFloatTfloat"; + + AlwaysNeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..facc26191c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ne_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ne_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysNeIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeIntTint"; + + AlwaysNeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..efae7f8ca1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_eq_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_eq_bigint_tbigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverEqBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqBigintTbigint"; + + EverEqBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..4666607d03 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_eq_float_tfloat: tests if a scalar is ever eq to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_eq_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverEqFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqFloatTfloat"; + + EverEqFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..23b5a3ff73 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_eq_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_eq_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverEqIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqIntTint"; + + EverEqIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGeBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..a6958eeea1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGeBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ge_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ge_bigint_tbigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGeBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGeBigintTbigint"; + + EverGeBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGeFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..f7b2285a4a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGeFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ge_float_tfloat: tests if a scalar is ever ge to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ge_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGeFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGeFloatTfloat"; + + EverGeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGeIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..ca303ca500 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGeIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ge_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ge_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGeIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGeIntTint"; + + EverGeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGtBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..8b9627dc43 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGtBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_gt_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_gt_bigint_tbigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGtBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGtBigintTbigint"; + + EverGtBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGtFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..f65720d26f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGtFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_gt_float_tfloat: tests if a scalar is ever gt to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_gt_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGtFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGtFloatTfloat"; + + EverGtFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGtIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..1ef281f21e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGtIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_gt_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_gt_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGtIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGtIntTint"; + + EverGtIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLeBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..6b55c629a2 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLeBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_le_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_le_bigint_tbigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLeBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLeBigintTbigint"; + + EverLeBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLeFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..bb4b73e4e7 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLeFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_le_float_tfloat: tests if a scalar is ever le to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_le_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLeFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLeFloatTfloat"; + + EverLeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLeIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..46271b029d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLeIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_le_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_le_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLeIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLeIntTint"; + + EverLeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLtBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..21c827c647 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLtBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_lt_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_lt_bigint_tbigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLtBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLtBigintTbigint"; + + EverLtBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLtFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..02c3deed81 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLtFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_lt_float_tfloat: tests if a scalar is ever lt to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_lt_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLtFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLtFloatTfloat"; + + EverLtFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLtIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..4d3c1ab05b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLtIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_lt_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_lt_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLtIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLtIntTint"; + + EverLtIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeBigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeBigintTbigintLogicalFunction.hpp new file mode 100644 index 0000000000..5b5ec3f630 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeBigintTbigintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ne_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ne_bigint_tbigint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverNeBigintTbigintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeBigintTbigint"; + + EverNeBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..dfce0f7d4a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ne_float_tfloat: tests if a scalar is ever ne to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ne_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverNeFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeFloatTfloat"; + + EverNeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..5de9645a64 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ne_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ne_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverNeIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeIntTint"; + + EverNeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..165908ab0c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqBigintTbigintLogicalFunction::AlwaysEqBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysEqBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysEqBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysEqBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysEqBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..236e3aae5b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqFloatTfloatLogicalFunction::AlwaysEqFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysEqFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysEqFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysEqFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysEqFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..2d39421d29 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqIntTintLogicalFunction::AlwaysEqIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysEqIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqIntTintLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysEqIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysEqIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysEqIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..1655a5f099 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGeBigintTbigintLogicalFunction::AlwaysGeBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGeBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGeBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGeBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGeBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGeBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGeBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool AlwaysGeBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGeBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGeBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGeBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGeBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGeBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..c2271278ed --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGeFloatTfloatLogicalFunction::AlwaysGeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGeFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGeFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGeFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGeFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGeFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGeFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysGeFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGeFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGeFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGeFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGeFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGeFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..e048ee1527 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGeIntTintLogicalFunction::AlwaysGeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGeIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGeIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGeIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGeIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGeIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGeIntTintLogicalFunction::getType() const { return NAME; } + +bool AlwaysGeIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGeIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGeIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGeIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGeIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGeIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..61388c58bc --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGtBigintTbigintLogicalFunction::AlwaysGtBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGtBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGtBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGtBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGtBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGtBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGtBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool AlwaysGtBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGtBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGtBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGtBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGtBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGtBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..4c7037a18f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGtFloatTfloatLogicalFunction::AlwaysGtFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGtFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGtFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGtFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGtFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGtFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGtFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysGtFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGtFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGtFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGtFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGtFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGtFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..a2bccc47c5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGtIntTintLogicalFunction::AlwaysGtIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGtIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGtIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGtIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGtIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGtIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGtIntTintLogicalFunction::getType() const { return NAME; } + +bool AlwaysGtIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGtIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGtIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGtIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGtIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGtIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..e90f5be0b9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLeBigintTbigintLogicalFunction::AlwaysLeBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLeBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLeBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLeBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLeBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLeBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLeBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool AlwaysLeBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLeBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLeBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLeBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLeBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLeBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..45900c97c2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLeFloatTfloatLogicalFunction::AlwaysLeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLeFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLeFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLeFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLeFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLeFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLeFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysLeFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLeFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLeFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLeFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLeFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLeFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..dfbe893fd9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLeIntTintLogicalFunction::AlwaysLeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLeIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLeIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLeIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLeIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLeIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLeIntTintLogicalFunction::getType() const { return NAME; } + +bool AlwaysLeIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLeIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLeIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLeIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLeIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLeIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..4d67ea2436 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLtBigintTbigintLogicalFunction::AlwaysLtBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLtBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLtBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLtBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLtBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLtBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLtBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool AlwaysLtBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLtBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLtBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLtBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLtBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLtBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..68eab07553 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLtFloatTfloatLogicalFunction::AlwaysLtFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLtFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLtFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLtFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLtFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLtFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLtFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysLtFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLtFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLtFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLtFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLtFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLtFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..186b96b2ca --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLtIntTintLogicalFunction::AlwaysLtIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLtIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLtIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLtIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLtIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLtIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLtIntTintLogicalFunction::getType() const { return NAME; } + +bool AlwaysLtIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLtIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLtIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLtIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLtIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLtIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..69e726068e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeBigintTbigintLogicalFunction::AlwaysNeBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysNeBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysNeBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysNeBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysNeBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..61d1593192 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeFloatTfloatLogicalFunction::AlwaysNeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysNeFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysNeFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysNeFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysNeFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..c18fd96ceb --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeIntTintLogicalFunction::AlwaysNeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysNeIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeIntTintLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysNeIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysNeIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysNeIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index ff6190bffd..09a8d54498 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -148,3 +148,39 @@ add_plugin(AlwaysGtTbigintTbigint LogicalFunction nes-logical-operators AlwaysGt add_plugin(AlwaysLeTbigintTbigint LogicalFunction nes-logical-operators AlwaysLeTbigintTbigintLogicalFunction.cpp) add_plugin(AlwaysLtTbigintTbigint LogicalFunction nes-logical-operators AlwaysLtTbigintTbigintLogicalFunction.cpp) add_plugin(AlwaysNeTbigintTbigint LogicalFunction nes-logical-operators AlwaysNeTbigintTbigintLogicalFunction.cpp) +add_plugin(EverEqFloatTfloat LogicalFunction nes-logical-operators EverEqFloatTfloatLogicalFunction.cpp) +add_plugin(EverGeFloatTfloat LogicalFunction nes-logical-operators EverGeFloatTfloatLogicalFunction.cpp) +add_plugin(EverGtFloatTfloat LogicalFunction nes-logical-operators EverGtFloatTfloatLogicalFunction.cpp) +add_plugin(EverLeFloatTfloat LogicalFunction nes-logical-operators EverLeFloatTfloatLogicalFunction.cpp) +add_plugin(EverLtFloatTfloat LogicalFunction nes-logical-operators EverLtFloatTfloatLogicalFunction.cpp) +add_plugin(EverNeFloatTfloat LogicalFunction nes-logical-operators EverNeFloatTfloatLogicalFunction.cpp) +add_plugin(EverEqIntTint LogicalFunction nes-logical-operators EverEqIntTintLogicalFunction.cpp) +add_plugin(EverGeIntTint LogicalFunction nes-logical-operators EverGeIntTintLogicalFunction.cpp) +add_plugin(EverGtIntTint LogicalFunction nes-logical-operators EverGtIntTintLogicalFunction.cpp) +add_plugin(EverLeIntTint LogicalFunction nes-logical-operators EverLeIntTintLogicalFunction.cpp) +add_plugin(EverLtIntTint LogicalFunction nes-logical-operators EverLtIntTintLogicalFunction.cpp) +add_plugin(EverNeIntTint LogicalFunction nes-logical-operators EverNeIntTintLogicalFunction.cpp) +add_plugin(EverEqBigintTbigint LogicalFunction nes-logical-operators EverEqBigintTbigintLogicalFunction.cpp) +add_plugin(EverGeBigintTbigint LogicalFunction nes-logical-operators EverGeBigintTbigintLogicalFunction.cpp) +add_plugin(EverGtBigintTbigint LogicalFunction nes-logical-operators EverGtBigintTbigintLogicalFunction.cpp) +add_plugin(EverLeBigintTbigint LogicalFunction nes-logical-operators EverLeBigintTbigintLogicalFunction.cpp) +add_plugin(EverLtBigintTbigint LogicalFunction nes-logical-operators EverLtBigintTbigintLogicalFunction.cpp) +add_plugin(EverNeBigintTbigint LogicalFunction nes-logical-operators EverNeBigintTbigintLogicalFunction.cpp) +add_plugin(AlwaysEqFloatTfloat LogicalFunction nes-logical-operators AlwaysEqFloatTfloatLogicalFunction.cpp) +add_plugin(AlwaysGeFloatTfloat LogicalFunction nes-logical-operators AlwaysGeFloatTfloatLogicalFunction.cpp) +add_plugin(AlwaysGtFloatTfloat LogicalFunction nes-logical-operators AlwaysGtFloatTfloatLogicalFunction.cpp) +add_plugin(AlwaysLeFloatTfloat LogicalFunction nes-logical-operators AlwaysLeFloatTfloatLogicalFunction.cpp) +add_plugin(AlwaysLtFloatTfloat LogicalFunction nes-logical-operators AlwaysLtFloatTfloatLogicalFunction.cpp) +add_plugin(AlwaysNeFloatTfloat LogicalFunction nes-logical-operators AlwaysNeFloatTfloatLogicalFunction.cpp) +add_plugin(AlwaysEqIntTint LogicalFunction nes-logical-operators AlwaysEqIntTintLogicalFunction.cpp) +add_plugin(AlwaysGeIntTint LogicalFunction nes-logical-operators AlwaysGeIntTintLogicalFunction.cpp) +add_plugin(AlwaysGtIntTint LogicalFunction nes-logical-operators AlwaysGtIntTintLogicalFunction.cpp) +add_plugin(AlwaysLeIntTint LogicalFunction nes-logical-operators AlwaysLeIntTintLogicalFunction.cpp) +add_plugin(AlwaysLtIntTint LogicalFunction nes-logical-operators AlwaysLtIntTintLogicalFunction.cpp) +add_plugin(AlwaysNeIntTint LogicalFunction nes-logical-operators AlwaysNeIntTintLogicalFunction.cpp) +add_plugin(AlwaysEqBigintTbigint LogicalFunction nes-logical-operators AlwaysEqBigintTbigintLogicalFunction.cpp) +add_plugin(AlwaysGeBigintTbigint LogicalFunction nes-logical-operators AlwaysGeBigintTbigintLogicalFunction.cpp) +add_plugin(AlwaysGtBigintTbigint LogicalFunction nes-logical-operators AlwaysGtBigintTbigintLogicalFunction.cpp) +add_plugin(AlwaysLeBigintTbigint LogicalFunction nes-logical-operators AlwaysLeBigintTbigintLogicalFunction.cpp) +add_plugin(AlwaysLtBigintTbigint LogicalFunction nes-logical-operators AlwaysLtBigintTbigintLogicalFunction.cpp) +add_plugin(AlwaysNeBigintTbigint LogicalFunction nes-logical-operators AlwaysNeBigintTbigintLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..bd7bc9bd8b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqBigintTbigintLogicalFunction::EverEqBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverEqBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool EverEqBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverEqBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverEqBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverEqBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverEqFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..d5f05bc4c5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqFloatTfloatLogicalFunction::EverEqFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverEqFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool EverEqFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverEqFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverEqFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverEqFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverEqIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..a8b84aa5c8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqIntTintLogicalFunction::EverEqIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverEqIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqIntTintLogicalFunction::getType() const { return NAME; } + +bool EverEqIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverEqIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverEqIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverEqIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..157c6360ea --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGeBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGeBigintTbigintLogicalFunction::EverGeBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGeBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGeBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGeBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGeBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGeBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGeBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool EverGeBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGeBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGeBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGeBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGeBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGeBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..38b434e735 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGeFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGeFloatTfloatLogicalFunction::EverGeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGeFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGeFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGeFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGeFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGeFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGeFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool EverGeFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGeFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGeFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGeFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGeFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGeFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..92ecec6983 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGeIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGeIntTintLogicalFunction::EverGeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGeIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGeIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGeIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGeIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGeIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGeIntTintLogicalFunction::getType() const { return NAME; } + +bool EverGeIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGeIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGeIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGeIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGeIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGeIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..77d6ddc6bb --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGtBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGtBigintTbigintLogicalFunction::EverGtBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGtBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGtBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGtBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGtBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGtBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGtBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool EverGtBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGtBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGtBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGtBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGtBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGtBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..c9b33257a7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGtFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGtFloatTfloatLogicalFunction::EverGtFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGtFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGtFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGtFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGtFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGtFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGtFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool EverGtFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGtFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGtFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGtFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGtFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGtFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..973c67c20c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGtIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGtIntTintLogicalFunction::EverGtIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGtIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGtIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGtIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGtIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGtIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGtIntTintLogicalFunction::getType() const { return NAME; } + +bool EverGtIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGtIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGtIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGtIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGtIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGtIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..08cf99bcde --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLeBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLeBigintTbigintLogicalFunction::EverLeBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLeBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLeBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLeBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLeBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLeBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLeBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool EverLeBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLeBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLeBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLeBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLeBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLeBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..8557750a57 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLeFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLeFloatTfloatLogicalFunction::EverLeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLeFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLeFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLeFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLeFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLeFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLeFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool EverLeFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLeFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLeFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLeFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLeFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLeFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..1fe564e5a0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLeIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLeIntTintLogicalFunction::EverLeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLeIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLeIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLeIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLeIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLeIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLeIntTintLogicalFunction::getType() const { return NAME; } + +bool EverLeIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLeIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLeIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLeIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLeIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLeIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..23a4675cd9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLtBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLtBigintTbigintLogicalFunction::EverLtBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLtBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLtBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLtBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLtBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLtBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLtBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool EverLtBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLtBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLtBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLtBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLtBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLtBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..c13e822a91 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLtFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLtFloatTfloatLogicalFunction::EverLtFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLtFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLtFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLtFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLtFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLtFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLtFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool EverLtFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLtFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLtFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLtFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLtFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLtFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..f94b21badb --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLtIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLtIntTintLogicalFunction::EverLtIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLtIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLtIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLtIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLtIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLtIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLtIntTintLogicalFunction::getType() const { return NAME; } + +bool EverLtIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLtIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLtIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLtIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLtIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLtIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeBigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeBigintTbigintLogicalFunction.cpp new file mode 100644 index 0000000000..12e7611d5f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeBigintTbigintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeBigintTbigintLogicalFunction::EverNeBigintTbigintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeBigintTbigintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeBigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeBigintTbigintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeBigintTbigintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverNeBigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeBigintTbigintLogicalFunction::getType() const { return NAME; } + +bool EverNeBigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeBigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverNeBigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverNeBigintTbigintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeBigintTbigintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeBigintTbigintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverNeBigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..2f9723e1a2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeFloatTfloatLogicalFunction::EverNeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverNeFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool EverNeFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverNeFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverNeFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverNeFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..4b26ccda1a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeIntTintLogicalFunction::EverNeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverNeIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeIntTintLogicalFunction::getType() const { return NAME; } + +bool EverNeIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverNeIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverNeIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverNeIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..2b35d1eec5 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_eq_bigint_tbigint`. + * + * Per-event always_eq_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysEqBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqBigintTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..0aa62b3f59 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_eq_float_tfloat`. + * + * Per-event always_eq_float_tfloat: tests if a scalar is ever eq to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysEqFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..19b2376946 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_eq_int_tint`. + * + * Per-event always_eq_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysEqIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..6273862456 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ge_bigint_tbigint`. + * + * Per-event always_ge_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGeBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGeBigintTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..e434ca62dc --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ge_float_tfloat`. + * + * Per-event always_ge_float_tfloat: tests if a scalar is ever ge to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGeFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGeFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..72c811601b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ge_int_tint`. + * + * Per-event always_ge_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGeIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGeIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..837f31024b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_gt_bigint_tbigint`. + * + * Per-event always_gt_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGtBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGtBigintTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..6ec423ab97 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_gt_float_tfloat`. + * + * Per-event always_gt_float_tfloat: tests if a scalar is ever gt to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGtFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGtFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..0e1cf32b7b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_gt_int_tint`. + * + * Per-event always_gt_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGtIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGtIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..b03bae0e62 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_le_bigint_tbigint`. + * + * Per-event always_le_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLeBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLeBigintTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..3ea6b2b734 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_le_float_tfloat`. + * + * Per-event always_le_float_tfloat: tests if a scalar is ever le to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLeFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLeFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..1c79f07981 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_le_int_tint`. + * + * Per-event always_le_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLeIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLeIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..111aa16311 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_lt_bigint_tbigint`. + * + * Per-event always_lt_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLtBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLtBigintTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..af2ddb3254 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_lt_float_tfloat`. + * + * Per-event always_lt_float_tfloat: tests if a scalar is ever lt to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLtFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLtFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..6ab3848163 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_lt_int_tint`. + * + * Per-event always_lt_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLtIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLtIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..1b3bccff1b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ne_bigint_tbigint`. + * + * Per-event always_ne_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysNeBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeBigintTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..b8d7b84c15 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ne_float_tfloat`. + * + * Per-event always_ne_float_tfloat: tests if a scalar is ever ne to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysNeFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..d38d41ae5a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ne_int_tint`. + * + * Per-event always_ne_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysNeIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..25c40ac239 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_eq_bigint_tbigint`. + * + * Per-event ever_eq_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverEqBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqBigintTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..f44db4fe5a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_eq_float_tfloat`. + * + * Per-event ever_eq_float_tfloat: tests if a scalar is ever eq to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverEqFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..d6fdeaa53a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_eq_int_tint`. + * + * Per-event ever_eq_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverEqIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGeBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..5713b4fedb --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGeBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ge_bigint_tbigint`. + * + * Per-event ever_ge_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGeBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGeBigintTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGeFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..b41e5d0f7e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGeFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ge_float_tfloat`. + * + * Per-event ever_ge_float_tfloat: tests if a scalar is ever ge to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGeFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGeFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGeIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..0d4aec75ec --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGeIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ge_int_tint`. + * + * Per-event ever_ge_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGeIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGeIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGtBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..b8b9a59577 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGtBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_gt_bigint_tbigint`. + * + * Per-event ever_gt_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGtBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGtBigintTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGtFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..cf44748abf --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGtFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_gt_float_tfloat`. + * + * Per-event ever_gt_float_tfloat: tests if a scalar is ever gt to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGtFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGtFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGtIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..13d66aded4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGtIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_gt_int_tint`. + * + * Per-event ever_gt_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGtIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGtIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLeBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..186b8bf9d2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLeBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_le_bigint_tbigint`. + * + * Per-event ever_le_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLeBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLeBigintTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLeFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..ad1b285874 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLeFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_le_float_tfloat`. + * + * Per-event ever_le_float_tfloat: tests if a scalar is ever le to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLeFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLeFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLeIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..0260d63939 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLeIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_le_int_tint`. + * + * Per-event ever_le_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLeIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLeIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLtBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..3496b311cd --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLtBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_lt_bigint_tbigint`. + * + * Per-event ever_lt_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLtBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLtBigintTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLtFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..02217926dd --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLtFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_lt_float_tfloat`. + * + * Per-event ever_lt_float_tfloat: tests if a scalar is ever lt to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLtFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLtFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLtIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..f447038773 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLtIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_lt_int_tint`. + * + * Per-event ever_lt_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLtIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLtIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeBigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeBigintTbigintPhysicalFunction.hpp new file mode 100644 index 0000000000..61cdf7d943 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeBigintTbigintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ne_bigint_tbigint`. + * + * Per-event ever_ne_bigint_tbigint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverNeBigintTbigintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeBigintTbigintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..084a68f0f4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ne_float_tfloat`. + * + * Per-event ever_ne_float_tfloat: tests if a scalar is ever ne to a single-instant tfloat value. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverNeFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..47c3375c13 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ne_int_tint`. + * + * Per-event ever_ne_int_tint: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverNeIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..48bb0541a1 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqBigintTbigintPhysicalFunction::AlwaysEqBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tbigint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_eq_bigint_tbigint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysEqBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..adbad75361 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqFloatTfloatPhysicalFunction::AlwaysEqFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", v, ts_str); + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_eq_float_tfloat(d, temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysEqFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..a43043a402 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqIntTintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqIntTintPhysicalFunction::AlwaysEqIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_eq_int_tint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysEqIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..27ecad58bc --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGeBigintTbigintPhysicalFunction::AlwaysGeBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGeBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tbigint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_ge_bigint_tbigint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGeBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGeBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGeBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..93855a2293 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGeFloatTfloatPhysicalFunction::AlwaysGeFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGeFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", v, ts_str); + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_ge_float_tfloat(d, temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGeFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGeFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGeFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..83fec1d6f1 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeIntTintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGeIntTintPhysicalFunction::AlwaysGeIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGeIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_ge_int_tint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGeIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGeIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGeIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..02b2f7e25c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGtBigintTbigintPhysicalFunction::AlwaysGtBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGtBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tbigint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_gt_bigint_tbigint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGtBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGtBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGtBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..9bf4cba71e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGtFloatTfloatPhysicalFunction::AlwaysGtFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGtFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", v, ts_str); + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_gt_float_tfloat(d, temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGtFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGtFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGtFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..0c49bcb409 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtIntTintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGtIntTintPhysicalFunction::AlwaysGtIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGtIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_gt_int_tint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGtIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGtIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGtIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..7ab05b7beb --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLeBigintTbigintPhysicalFunction::AlwaysLeBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLeBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tbigint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_le_bigint_tbigint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLeBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLeBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLeBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..f69c9bd365 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLeFloatTfloatPhysicalFunction::AlwaysLeFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLeFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", v, ts_str); + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_le_float_tfloat(d, temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLeFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLeFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLeFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..1611434857 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeIntTintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLeIntTintPhysicalFunction::AlwaysLeIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLeIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_le_int_tint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLeIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLeIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLeIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..04418bb813 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLtBigintTbigintPhysicalFunction::AlwaysLtBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLtBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tbigint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_lt_bigint_tbigint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLtBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLtBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLtBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..224a4d41b0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLtFloatTfloatPhysicalFunction::AlwaysLtFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLtFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", v, ts_str); + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_lt_float_tfloat(d, temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLtFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLtFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLtFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..c4d6aee74a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtIntTintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLtIntTintPhysicalFunction::AlwaysLtIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLtIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_lt_int_tint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLtIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLtIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLtIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..efc2b248c5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeBigintTbigintPhysicalFunction::AlwaysNeBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tbigint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_ne_bigint_tbigint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysNeBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..86929b6420 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeFloatTfloatPhysicalFunction::AlwaysNeFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", v, ts_str); + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_ne_float_tfloat(d, temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysNeFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..31a2bed532 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeIntTintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeIntTintPhysicalFunction::AlwaysNeIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_ne_int_tint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysNeIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 1bd1c2eae2..bd3c465f90 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -147,4 +147,40 @@ add_plugin(AlwaysGtTbigintTbigint PhysicalFunction nes-physical-operators Always add_plugin(AlwaysLeTbigintTbigint PhysicalFunction nes-physical-operators AlwaysLeTbigintTbigintPhysicalFunction.cpp) add_plugin(AlwaysLtTbigintTbigint PhysicalFunction nes-physical-operators AlwaysLtTbigintTbigintPhysicalFunction.cpp) add_plugin(AlwaysNeTbigintTbigint PhysicalFunction nes-physical-operators AlwaysNeTbigintTbigintPhysicalFunction.cpp) +add_plugin(EverEqFloatTfloat PhysicalFunction nes-physical-operators EverEqFloatTfloatPhysicalFunction.cpp) +add_plugin(EverGeFloatTfloat PhysicalFunction nes-physical-operators EverGeFloatTfloatPhysicalFunction.cpp) +add_plugin(EverGtFloatTfloat PhysicalFunction nes-physical-operators EverGtFloatTfloatPhysicalFunction.cpp) +add_plugin(EverLeFloatTfloat PhysicalFunction nes-physical-operators EverLeFloatTfloatPhysicalFunction.cpp) +add_plugin(EverLtFloatTfloat PhysicalFunction nes-physical-operators EverLtFloatTfloatPhysicalFunction.cpp) +add_plugin(EverNeFloatTfloat PhysicalFunction nes-physical-operators EverNeFloatTfloatPhysicalFunction.cpp) +add_plugin(EverEqIntTint PhysicalFunction nes-physical-operators EverEqIntTintPhysicalFunction.cpp) +add_plugin(EverGeIntTint PhysicalFunction nes-physical-operators EverGeIntTintPhysicalFunction.cpp) +add_plugin(EverGtIntTint PhysicalFunction nes-physical-operators EverGtIntTintPhysicalFunction.cpp) +add_plugin(EverLeIntTint PhysicalFunction nes-physical-operators EverLeIntTintPhysicalFunction.cpp) +add_plugin(EverLtIntTint PhysicalFunction nes-physical-operators EverLtIntTintPhysicalFunction.cpp) +add_plugin(EverNeIntTint PhysicalFunction nes-physical-operators EverNeIntTintPhysicalFunction.cpp) +add_plugin(EverEqBigintTbigint PhysicalFunction nes-physical-operators EverEqBigintTbigintPhysicalFunction.cpp) +add_plugin(EverGeBigintTbigint PhysicalFunction nes-physical-operators EverGeBigintTbigintPhysicalFunction.cpp) +add_plugin(EverGtBigintTbigint PhysicalFunction nes-physical-operators EverGtBigintTbigintPhysicalFunction.cpp) +add_plugin(EverLeBigintTbigint PhysicalFunction nes-physical-operators EverLeBigintTbigintPhysicalFunction.cpp) +add_plugin(EverLtBigintTbigint PhysicalFunction nes-physical-operators EverLtBigintTbigintPhysicalFunction.cpp) +add_plugin(EverNeBigintTbigint PhysicalFunction nes-physical-operators EverNeBigintTbigintPhysicalFunction.cpp) +add_plugin(AlwaysEqFloatTfloat PhysicalFunction nes-physical-operators AlwaysEqFloatTfloatPhysicalFunction.cpp) +add_plugin(AlwaysGeFloatTfloat PhysicalFunction nes-physical-operators AlwaysGeFloatTfloatPhysicalFunction.cpp) +add_plugin(AlwaysGtFloatTfloat PhysicalFunction nes-physical-operators AlwaysGtFloatTfloatPhysicalFunction.cpp) +add_plugin(AlwaysLeFloatTfloat PhysicalFunction nes-physical-operators AlwaysLeFloatTfloatPhysicalFunction.cpp) +add_plugin(AlwaysLtFloatTfloat PhysicalFunction nes-physical-operators AlwaysLtFloatTfloatPhysicalFunction.cpp) +add_plugin(AlwaysNeFloatTfloat PhysicalFunction nes-physical-operators AlwaysNeFloatTfloatPhysicalFunction.cpp) +add_plugin(AlwaysEqIntTint PhysicalFunction nes-physical-operators AlwaysEqIntTintPhysicalFunction.cpp) +add_plugin(AlwaysGeIntTint PhysicalFunction nes-physical-operators AlwaysGeIntTintPhysicalFunction.cpp) +add_plugin(AlwaysGtIntTint PhysicalFunction nes-physical-operators AlwaysGtIntTintPhysicalFunction.cpp) +add_plugin(AlwaysLeIntTint PhysicalFunction nes-physical-operators AlwaysLeIntTintPhysicalFunction.cpp) +add_plugin(AlwaysLtIntTint PhysicalFunction nes-physical-operators AlwaysLtIntTintPhysicalFunction.cpp) +add_plugin(AlwaysNeIntTint PhysicalFunction nes-physical-operators AlwaysNeIntTintPhysicalFunction.cpp) +add_plugin(AlwaysEqBigintTbigint PhysicalFunction nes-physical-operators AlwaysEqBigintTbigintPhysicalFunction.cpp) +add_plugin(AlwaysGeBigintTbigint PhysicalFunction nes-physical-operators AlwaysGeBigintTbigintPhysicalFunction.cpp) +add_plugin(AlwaysGtBigintTbigint PhysicalFunction nes-physical-operators AlwaysGtBigintTbigintPhysicalFunction.cpp) +add_plugin(AlwaysLeBigintTbigint PhysicalFunction nes-physical-operators AlwaysLeBigintTbigintPhysicalFunction.cpp) +add_plugin(AlwaysLtBigintTbigint PhysicalFunction nes-physical-operators AlwaysLtBigintTbigintPhysicalFunction.cpp) +add_plugin(AlwaysNeBigintTbigint PhysicalFunction nes-physical-operators AlwaysNeBigintTbigintPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/EverEqBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..b287987b4f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqBigintTbigintPhysicalFunction::EverEqBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverEqBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tbigint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_eq_bigint_tbigint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverEqBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverEqFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..56093e5c87 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqFloatTfloatPhysicalFunction::EverEqFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverEqFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", v, ts_str); + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_eq_float_tfloat(d, temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverEqFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverEqIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..0a6d80b3c6 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqIntTintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqIntTintPhysicalFunction::EverEqIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverEqIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_eq_int_tint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverEqIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGeBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..11e9eb48d4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGeBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGeBigintTbigintPhysicalFunction::EverGeBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGeBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tbigint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_ge_bigint_tbigint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGeBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGeBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGeBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGeFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..003cb07439 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGeFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGeFloatTfloatPhysicalFunction::EverGeFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGeFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", v, ts_str); + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_ge_float_tfloat(d, temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGeFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGeFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGeFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGeIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..591d6da944 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGeIntTintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGeIntTintPhysicalFunction::EverGeIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGeIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_ge_int_tint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGeIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGeIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGeIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGtBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..93b2b47576 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGtBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGtBigintTbigintPhysicalFunction::EverGtBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGtBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tbigint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_gt_bigint_tbigint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGtBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGtBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGtBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGtFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..21979000ba --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGtFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGtFloatTfloatPhysicalFunction::EverGtFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGtFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", v, ts_str); + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_gt_float_tfloat(d, temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGtFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGtFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGtFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGtIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..a3cdf414ed --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGtIntTintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGtIntTintPhysicalFunction::EverGtIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGtIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_gt_int_tint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGtIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGtIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGtIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLeBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..df155c47aa --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLeBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLeBigintTbigintPhysicalFunction::EverLeBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLeBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tbigint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_le_bigint_tbigint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLeBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLeBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLeBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLeFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..647b06a520 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLeFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLeFloatTfloatPhysicalFunction::EverLeFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLeFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", v, ts_str); + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_le_float_tfloat(d, temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLeFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLeFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLeFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLeIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..b04ec7be4f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLeIntTintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLeIntTintPhysicalFunction::EverLeIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLeIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_le_int_tint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLeIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLeIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLeIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLtBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..415516e939 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLtBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLtBigintTbigintPhysicalFunction::EverLtBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLtBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tbigint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_lt_bigint_tbigint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLtBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLtBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLtBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLtFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..445ac1ee7f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLtFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLtFloatTfloatPhysicalFunction::EverLtFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLtFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", v, ts_str); + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_lt_float_tfloat(d, temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLtFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLtFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLtFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLtIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..6f3120d6ff --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLtIntTintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLtIntTintPhysicalFunction::EverLtIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLtIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_lt_int_tint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLtIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLtIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLtIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeBigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeBigintTbigintPhysicalFunction.cpp new file mode 100644 index 0000000000..e1bb0ccf09 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeBigintTbigintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeBigintTbigintPhysicalFunction::EverNeBigintTbigintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverNeBigintTbigintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tbigint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_ne_bigint_tbigint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeBigintTbigintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeBigintTbigintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverNeBigintTbigintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..f0ca251bcd --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeFloatTfloatPhysicalFunction::EverNeFloatTfloatPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverNeFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", v, ts_str); + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_ne_float_tfloat(d, temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverNeFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..e9ad540bb1 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeIntTintPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeIntTintPhysicalFunction::EverNeIntTintPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverNeIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double d, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", static_cast(v), ts_str); + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_ne_int_tint(static_cast(d), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverNeIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index e445bb7205..648ccc7e2c 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -486,6 +486,12 @@ TEMPORAL_SEQUENCE: 'TEMPORAL_SEQUENCE' | 'temporal_sequence'; TEMPORAL_EINTERSECTS_GEOMETRY: 'TEMPORAL_EINTERSECTS_GEOMETRY' | 'temporal_eintersects_geometry'; TEMPORAL_AINTERSECTS_GEOMETRY: 'TEMPORAL_AINTERSECTS_GEOMETRY' | 'temporal_aintersects_geometry'; TEMPORAL_ECONTAINS_GEOMETRY: 'TEMPORAL_ECONTAINS_GEOMETRY' | 'temporal_econtains_geometry'; +ALWAYS_EQ_BIGINT_TBIGINT: 'ALWAYS_EQ_BIGINT_TBIGINT' | 'always_eq_bigint_tbigint'; +ALWAYS_GE_BIGINT_TBIGINT: 'ALWAYS_GE_BIGINT_TBIGINT' | 'always_ge_bigint_tbigint'; +ALWAYS_GT_BIGINT_TBIGINT: 'ALWAYS_GT_BIGINT_TBIGINT' | 'always_gt_bigint_tbigint'; +ALWAYS_LE_BIGINT_TBIGINT: 'ALWAYS_LE_BIGINT_TBIGINT' | 'always_le_bigint_tbigint'; +ALWAYS_LT_BIGINT_TBIGINT: 'ALWAYS_LT_BIGINT_TBIGINT' | 'always_lt_bigint_tbigint'; +ALWAYS_NE_BIGINT_TBIGINT: 'ALWAYS_NE_BIGINT_TBIGINT' | 'always_ne_bigint_tbigint'; ALWAYS_EQ_TBIGINT_BIGINT: 'ALWAYS_EQ_TBIGINT_BIGINT' | 'always_eq_tbigint_bigint'; ALWAYS_GE_TBIGINT_BIGINT: 'ALWAYS_GE_TBIGINT_BIGINT' | 'always_ge_tbigint_bigint'; ALWAYS_GT_TBIGINT_BIGINT: 'ALWAYS_GT_TBIGINT_BIGINT' | 'always_gt_tbigint_bigint'; @@ -498,6 +504,12 @@ ALWAYS_GT_TBIGINT_TBIGINT: 'ALWAYS_GT_TBIGINT_TBIGINT' | 'always_gt_tbigint_tbig ALWAYS_LE_TBIGINT_TBIGINT: 'ALWAYS_LE_TBIGINT_TBIGINT' | 'always_le_tbigint_tbigint'; ALWAYS_LT_TBIGINT_TBIGINT: 'ALWAYS_LT_TBIGINT_TBIGINT' | 'always_lt_tbigint_tbigint'; ALWAYS_NE_TBIGINT_TBIGINT: 'ALWAYS_NE_TBIGINT_TBIGINT' | 'always_ne_tbigint_tbigint'; +ALWAYS_EQ_FLOAT_TFLOAT: 'ALWAYS_EQ_FLOAT_TFLOAT' | 'always_eq_float_tfloat'; +ALWAYS_GE_FLOAT_TFLOAT: 'ALWAYS_GE_FLOAT_TFLOAT' | 'always_ge_float_tfloat'; +ALWAYS_GT_FLOAT_TFLOAT: 'ALWAYS_GT_FLOAT_TFLOAT' | 'always_gt_float_tfloat'; +ALWAYS_LE_FLOAT_TFLOAT: 'ALWAYS_LE_FLOAT_TFLOAT' | 'always_le_float_tfloat'; +ALWAYS_LT_FLOAT_TFLOAT: 'ALWAYS_LT_FLOAT_TFLOAT' | 'always_lt_float_tfloat'; +ALWAYS_NE_FLOAT_TFLOAT: 'ALWAYS_NE_FLOAT_TFLOAT' | 'always_ne_float_tfloat'; ALWAYS_EQ_TFLOAT_FLOAT: 'ALWAYS_EQ_TFLOAT_FLOAT' | 'always_eq_tfloat_float'; ALWAYS_GE_TFLOAT_FLOAT: 'ALWAYS_GE_TFLOAT_FLOAT' | 'always_ge_tfloat_float'; ALWAYS_GT_TFLOAT_FLOAT: 'ALWAYS_GT_TFLOAT_FLOAT' | 'always_gt_tfloat_float'; @@ -510,6 +522,12 @@ ALWAYS_GT_TFLOAT_TFLOAT: 'ALWAYS_GT_TFLOAT_TFLOAT' | 'always_gt_tfloat_tfloat'; ALWAYS_LE_TFLOAT_TFLOAT: 'ALWAYS_LE_TFLOAT_TFLOAT' | 'always_le_tfloat_tfloat'; ALWAYS_LT_TFLOAT_TFLOAT: 'ALWAYS_LT_TFLOAT_TFLOAT' | 'always_lt_tfloat_tfloat'; ALWAYS_NE_TFLOAT_TFLOAT: 'ALWAYS_NE_TFLOAT_TFLOAT' | 'always_ne_tfloat_tfloat'; +ALWAYS_EQ_INT_TINT: 'ALWAYS_EQ_INT_TINT' | 'always_eq_int_tint'; +ALWAYS_GE_INT_TINT: 'ALWAYS_GE_INT_TINT' | 'always_ge_int_tint'; +ALWAYS_GT_INT_TINT: 'ALWAYS_GT_INT_TINT' | 'always_gt_int_tint'; +ALWAYS_LE_INT_TINT: 'ALWAYS_LE_INT_TINT' | 'always_le_int_tint'; +ALWAYS_LT_INT_TINT: 'ALWAYS_LT_INT_TINT' | 'always_lt_int_tint'; +ALWAYS_NE_INT_TINT: 'ALWAYS_NE_INT_TINT' | 'always_ne_int_tint'; ALWAYS_EQ_TINT_INT: 'ALWAYS_EQ_TINT_INT' | 'always_eq_tint_int'; ALWAYS_GE_TINT_INT: 'ALWAYS_GE_TINT_INT' | 'always_ge_tint_int'; ALWAYS_GT_TINT_INT: 'ALWAYS_GT_TINT_INT' | 'always_gt_tint_int'; @@ -523,6 +541,12 @@ ALWAYS_LE_TINT_TINT: 'ALWAYS_LE_TINT_TINT' | 'always_le_tint_tint'; ALWAYS_LT_TINT_TINT: 'ALWAYS_LT_TINT_TINT' | 'always_lt_tint_tint'; ALWAYS_NE_TINT_TINT: 'ALWAYS_NE_TINT_TINT' | 'always_ne_tint_tint'; EDWITHIN_TGEO_GEO: 'EDWITHIN_TGEO_GEO' | 'edwithin_tgeo_geo'; +EVER_EQ_BIGINT_TBIGINT: 'EVER_EQ_BIGINT_TBIGINT' | 'ever_eq_bigint_tbigint'; +EVER_GE_BIGINT_TBIGINT: 'EVER_GE_BIGINT_TBIGINT' | 'ever_ge_bigint_tbigint'; +EVER_GT_BIGINT_TBIGINT: 'EVER_GT_BIGINT_TBIGINT' | 'ever_gt_bigint_tbigint'; +EVER_LE_BIGINT_TBIGINT: 'EVER_LE_BIGINT_TBIGINT' | 'ever_le_bigint_tbigint'; +EVER_LT_BIGINT_TBIGINT: 'EVER_LT_BIGINT_TBIGINT' | 'ever_lt_bigint_tbigint'; +EVER_NE_BIGINT_TBIGINT: 'EVER_NE_BIGINT_TBIGINT' | 'ever_ne_bigint_tbigint'; EVER_EQ_TBIGINT_BIGINT: 'EVER_EQ_TBIGINT_BIGINT' | 'ever_eq_tbigint_bigint'; EVER_GE_TBIGINT_BIGINT: 'EVER_GE_TBIGINT_BIGINT' | 'ever_ge_tbigint_bigint'; EVER_GT_TBIGINT_BIGINT: 'EVER_GT_TBIGINT_BIGINT' | 'ever_gt_tbigint_bigint'; @@ -535,6 +559,12 @@ EVER_GT_TBIGINT_TBIGINT: 'EVER_GT_TBIGINT_TBIGINT' | 'ever_gt_tbigint_tbigint'; EVER_LE_TBIGINT_TBIGINT: 'EVER_LE_TBIGINT_TBIGINT' | 'ever_le_tbigint_tbigint'; EVER_LT_TBIGINT_TBIGINT: 'EVER_LT_TBIGINT_TBIGINT' | 'ever_lt_tbigint_tbigint'; EVER_NE_TBIGINT_TBIGINT: 'EVER_NE_TBIGINT_TBIGINT' | 'ever_ne_tbigint_tbigint'; +EVER_EQ_FLOAT_TFLOAT: 'EVER_EQ_FLOAT_TFLOAT' | 'ever_eq_float_tfloat'; +EVER_GE_FLOAT_TFLOAT: 'EVER_GE_FLOAT_TFLOAT' | 'ever_ge_float_tfloat'; +EVER_GT_FLOAT_TFLOAT: 'EVER_GT_FLOAT_TFLOAT' | 'ever_gt_float_tfloat'; +EVER_LE_FLOAT_TFLOAT: 'EVER_LE_FLOAT_TFLOAT' | 'ever_le_float_tfloat'; +EVER_LT_FLOAT_TFLOAT: 'EVER_LT_FLOAT_TFLOAT' | 'ever_lt_float_tfloat'; +EVER_NE_FLOAT_TFLOAT: 'EVER_NE_FLOAT_TFLOAT' | 'ever_ne_float_tfloat'; EVER_EQ_TFLOAT_FLOAT: 'EVER_EQ_TFLOAT_FLOAT' | 'ever_eq_tfloat_float'; EVER_GE_TFLOAT_FLOAT: 'EVER_GE_TFLOAT_FLOAT' | 'ever_ge_tfloat_float'; EVER_GT_TFLOAT_FLOAT: 'EVER_GT_TFLOAT_FLOAT' | 'ever_gt_tfloat_float'; @@ -547,6 +577,12 @@ EVER_GT_TFLOAT_TFLOAT: 'EVER_GT_TFLOAT_TFLOAT' | 'ever_gt_tfloat_tfloat'; EVER_LE_TFLOAT_TFLOAT: 'EVER_LE_TFLOAT_TFLOAT' | 'ever_le_tfloat_tfloat'; EVER_LT_TFLOAT_TFLOAT: 'EVER_LT_TFLOAT_TFLOAT' | 'ever_lt_tfloat_tfloat'; EVER_NE_TFLOAT_TFLOAT: 'EVER_NE_TFLOAT_TFLOAT' | 'ever_ne_tfloat_tfloat'; +EVER_EQ_INT_TINT: 'EVER_EQ_INT_TINT' | 'ever_eq_int_tint'; +EVER_GE_INT_TINT: 'EVER_GE_INT_TINT' | 'ever_ge_int_tint'; +EVER_GT_INT_TINT: 'EVER_GT_INT_TINT' | 'ever_gt_int_tint'; +EVER_LE_INT_TINT: 'EVER_LE_INT_TINT' | 'ever_le_int_tint'; +EVER_LT_INT_TINT: 'EVER_LT_INT_TINT' | 'ever_lt_int_tint'; +EVER_NE_INT_TINT: 'EVER_NE_INT_TINT' | 'ever_ne_int_tint'; EVER_EQ_TINT_INT: 'EVER_EQ_TINT_INT' | 'ever_eq_tint_int'; EVER_GE_TINT_INT: 'EVER_GE_TINT_INT' | 'ever_ge_tint_int'; EVER_GT_TINT_INT: 'EVER_GT_TINT_INT' | 'ever_gt_tint_int'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 1c1b52c852..aa7d1263e5 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -199,6 +199,42 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -2986,6 +3022,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TINT_TO_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_BIGINT_TBIGINT */ + case AntlrSQLLexer::EVER_EQ_BIGINT_TBIGINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_BIGINT_TBIGINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqBigintTbigintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_BIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GE_BIGINT_TBIGINT */ + case AntlrSQLLexer::EVER_GE_BIGINT_TBIGINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GE_BIGINT_TBIGINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGeBigintTbigintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_GE_BIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GT_BIGINT_TBIGINT */ + case AntlrSQLLexer::EVER_GT_BIGINT_TBIGINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GT_BIGINT_TBIGINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGtBigintTbigintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_GT_BIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LE_BIGINT_TBIGINT */ + case AntlrSQLLexer::EVER_LE_BIGINT_TBIGINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LE_BIGINT_TBIGINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLeBigintTbigintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_LE_BIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LT_BIGINT_TBIGINT */ + case AntlrSQLLexer::EVER_LT_BIGINT_TBIGINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LT_BIGINT_TBIGINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLtBigintTbigintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_LT_BIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_BIGINT_TBIGINT */ + case AntlrSQLLexer::EVER_NE_BIGINT_TBIGINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_BIGINT_TBIGINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeBigintTbigintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_NE_BIGINT_TBIGINT */ /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TBIGINT_BIGINT */ case AntlrSQLLexer::EVER_EQ_TBIGINT_BIGINT: { @@ -3334,6 +3544,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: EVER_NE_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_FLOAT_TFLOAT */ + case AntlrSQLLexer::EVER_EQ_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GE_FLOAT_TFLOAT */ + case AntlrSQLLexer::EVER_GE_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GE_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGeFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_GE_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GT_FLOAT_TFLOAT */ + case AntlrSQLLexer::EVER_GT_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GT_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGtFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_GT_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LE_FLOAT_TFLOAT */ + case AntlrSQLLexer::EVER_LE_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LE_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLeFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_LE_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LT_FLOAT_TFLOAT */ + case AntlrSQLLexer::EVER_LT_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LT_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLtFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_LT_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_FLOAT_TFLOAT */ + case AntlrSQLLexer::EVER_NE_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_NE_FLOAT_TFLOAT */ /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::EVER_EQ_TFLOAT_FLOAT: { @@ -3682,6 +4066,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: EVER_NE_TFLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_INT_TINT */ + case AntlrSQLLexer::EVER_EQ_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GE_INT_TINT */ + case AntlrSQLLexer::EVER_GE_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GE_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGeIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_GE_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GT_INT_TINT */ + case AntlrSQLLexer::EVER_GT_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GT_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGtIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_GT_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LE_INT_TINT */ + case AntlrSQLLexer::EVER_LE_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LE_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLeIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_LE_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LT_INT_TINT */ + case AntlrSQLLexer::EVER_LT_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LT_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLtIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_LT_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_INT_TINT */ + case AntlrSQLLexer::EVER_NE_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_NE_INT_TINT */ /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TINT_INT */ case AntlrSQLLexer::EVER_EQ_TINT_INT: { @@ -3977,10 +4535,184 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont { const auto argCount = context->expression().size(); if (argCount != 3) - throw InvalidQuerySyntax("EVER_LT_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + throw InvalidQuerySyntax("EVER_LT_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLtTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LT_TINT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_TINT_TINT */ + case AntlrSQLLexer::EVER_NE_TINT_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeTintTintLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_NE_TINT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_INT_TINT */ + case AntlrSQLLexer::ALWAYS_EQ_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GE_INT_TINT */ + case AntlrSQLLexer::ALWAYS_GE_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GE_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGeIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GE_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GT_INT_TINT */ + case AntlrSQLLexer::ALWAYS_GT_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GT_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGtIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GT_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LE_INT_TINT */ + case AntlrSQLLexer::ALWAYS_LE_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LE_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLeIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LE_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LT_INT_TINT */ + case AntlrSQLLexer::ALWAYS_LT_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LT_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); while (!helpers.top().constantBuilder.empty()) - { + {{ auto constantValue = std::move(helpers.top().constantBuilder.back()); helpers.top().constantBuilder.pop_back(); DataType dataType; @@ -3991,25 +4723,25 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont else dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); - } + }} auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); - helpers.top().functionBuilder.emplace_back(EverLtTintTintLogicalFunction(a0, a1, a2)); - } + helpers.top().functionBuilder.emplace_back(AlwaysLtIntTintLogicalFunction(a0, a1, a2)); + }} break; - /* END CODEGEN PARSER GLUE: EVER_LT_TINT_TINT */ - /* BEGIN CODEGEN PARSER GLUE: EVER_NE_TINT_TINT */ - case AntlrSQLLexer::EVER_NE_TINT_TINT: - { + /* END CODEGEN PARSER GLUE: ALWAYS_LT_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_INT_TINT */ + case AntlrSQLLexer::ALWAYS_NE_INT_TINT: + {{ const auto argCount = context->expression().size(); if (argCount != 3) - throw InvalidQuerySyntax("EVER_NE_TINT_TINT requires exactly 3 arguments, but got {}", argCount); + throw InvalidQuerySyntax("ALWAYS_NE_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); while (!helpers.top().constantBuilder.empty()) - { + {{ auto constantValue = std::move(helpers.top().constantBuilder.back()); helpers.top().constantBuilder.pop_back(); DataType dataType; @@ -4020,16 +4752,16 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont else dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); - } + }} auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); - helpers.top().functionBuilder.emplace_back(EverNeTintTintLogicalFunction(a0, a1, a2)); - } + helpers.top().functionBuilder.emplace_back(AlwaysNeIntTintLogicalFunction(a0, a1, a2)); + }} break; - /* END CODEGEN PARSER GLUE: EVER_NE_TINT_TINT */ + /* END CODEGEN PARSER GLUE: ALWAYS_NE_INT_TINT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TINT_INT */ case AntlrSQLLexer::ALWAYS_EQ_TINT_INT: { @@ -4378,6 +5110,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: ALWAYS_NE_TINT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_BIGINT_TBIGINT */ + case AntlrSQLLexer::ALWAYS_EQ_BIGINT_TBIGINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_BIGINT_TBIGINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqBigintTbigintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_BIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GE_BIGINT_TBIGINT */ + case AntlrSQLLexer::ALWAYS_GE_BIGINT_TBIGINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GE_BIGINT_TBIGINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGeBigintTbigintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GE_BIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GT_BIGINT_TBIGINT */ + case AntlrSQLLexer::ALWAYS_GT_BIGINT_TBIGINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GT_BIGINT_TBIGINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGtBigintTbigintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GT_BIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LE_BIGINT_TBIGINT */ + case AntlrSQLLexer::ALWAYS_LE_BIGINT_TBIGINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LE_BIGINT_TBIGINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLeBigintTbigintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LE_BIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LT_BIGINT_TBIGINT */ + case AntlrSQLLexer::ALWAYS_LT_BIGINT_TBIGINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LT_BIGINT_TBIGINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLtBigintTbigintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LT_BIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_BIGINT_TBIGINT */ + case AntlrSQLLexer::ALWAYS_NE_BIGINT_TBIGINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_NE_BIGINT_TBIGINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysNeBigintTbigintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_NE_BIGINT_TBIGINT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TBIGINT_BIGINT */ case AntlrSQLLexer::ALWAYS_EQ_TBIGINT_BIGINT: { @@ -4726,6 +5632,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: ALWAYS_NE_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_FLOAT_TFLOAT */ + case AntlrSQLLexer::ALWAYS_EQ_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GE_FLOAT_TFLOAT */ + case AntlrSQLLexer::ALWAYS_GE_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GE_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGeFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GE_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GT_FLOAT_TFLOAT */ + case AntlrSQLLexer::ALWAYS_GT_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GT_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGtFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GT_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LE_FLOAT_TFLOAT */ + case AntlrSQLLexer::ALWAYS_LE_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LE_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLeFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LE_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LT_FLOAT_TFLOAT */ + case AntlrSQLLexer::ALWAYS_LT_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LT_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLtFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LT_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_FLOAT_TFLOAT */ + case AntlrSQLLexer::ALWAYS_NE_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_NE_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysNeFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_NE_FLOAT_TFLOAT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 2a5c93f1608d3f725d6fb7015a489880b3a877ce Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 10:21:26 +0200 Subject: [PATCH 32/86] feat(meos): add EVER/ALWAYS_EQ/NE_{TBOOL_BOOL,BOOL_TBOOL} NES operators (W79-W82) Adds 8 per-event NES operators for tbool comparisons: EVER_EQ/NE_TBOOL_BOOL, ALWAYS_EQ/NE_TBOOL_BOOL (temporal-first form) and EVER_EQ/NE_BOOL_TBOOL, ALWAYS_EQ/NE_BOOL_TBOOL (reversed scalar-first form). tbool supports only EQ and NE (no ordered comparisons). Each 3-arg operator takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64); the temporal arg maps non-zero double to 't', zero to 'f' and is parsed with tbool_in(). The reversed form passes the scalar bool as the first argument to ever_eq_bool_tbool / always_eq_bool_tbool. Wired across all five locations. --- .../Meos/AlwaysEqBoolTboolLogicalFunction.hpp | 54 ++++ .../Meos/AlwaysEqTboolBoolLogicalFunction.hpp | 54 ++++ .../Meos/AlwaysNeBoolTboolLogicalFunction.hpp | 54 ++++ .../Meos/AlwaysNeTboolBoolLogicalFunction.hpp | 54 ++++ .../Meos/EverEqBoolTboolLogicalFunction.hpp | 54 ++++ .../Meos/EverEqTboolBoolLogicalFunction.hpp | 54 ++++ .../Meos/EverNeBoolTboolLogicalFunction.hpp | 54 ++++ .../Meos/EverNeTboolBoolLogicalFunction.hpp | 54 ++++ .../Meos/AlwaysEqBoolTboolLogicalFunction.cpp | 105 ++++++++ .../Meos/AlwaysEqTboolBoolLogicalFunction.cpp | 105 ++++++++ .../Meos/AlwaysNeBoolTboolLogicalFunction.cpp | 105 ++++++++ .../Meos/AlwaysNeTboolBoolLogicalFunction.cpp | 105 ++++++++ .../src/Functions/Meos/CMakeLists.txt | 8 + .../Meos/EverEqBoolTboolLogicalFunction.cpp | 105 ++++++++ .../Meos/EverEqTboolBoolLogicalFunction.cpp | 105 ++++++++ .../Meos/EverNeBoolTboolLogicalFunction.cpp | 105 ++++++++ .../Meos/EverNeTboolBoolLogicalFunction.cpp | 105 ++++++++ .../AlwaysEqBoolTboolPhysicalFunction.hpp | 43 ++++ .../AlwaysEqTboolBoolPhysicalFunction.hpp | 43 ++++ .../AlwaysNeBoolTboolPhysicalFunction.hpp | 43 ++++ .../AlwaysNeTboolBoolPhysicalFunction.hpp | 43 ++++ .../Meos/EverEqBoolTboolPhysicalFunction.hpp | 43 ++++ .../Meos/EverEqTboolBoolPhysicalFunction.hpp | 43 ++++ .../Meos/EverNeBoolTboolPhysicalFunction.hpp | 43 ++++ .../Meos/EverNeTboolBoolPhysicalFunction.hpp | 43 ++++ .../AlwaysEqBoolTboolPhysicalFunction.cpp | 89 +++++++ .../AlwaysEqTboolBoolPhysicalFunction.cpp | 89 +++++++ .../AlwaysNeBoolTboolPhysicalFunction.cpp | 89 +++++++ .../AlwaysNeTboolBoolPhysicalFunction.cpp | 89 +++++++ .../src/Functions/Meos/CMakeLists.txt | 8 + .../Meos/EverEqBoolTboolPhysicalFunction.cpp | 89 +++++++ .../Meos/EverEqTboolBoolPhysicalFunction.cpp | 89 +++++++ .../Meos/EverNeBoolTboolPhysicalFunction.cpp | 89 +++++++ .../Meos/EverNeTboolBoolPhysicalFunction.cpp | 89 +++++++ nes-sql-parser/AntlrSQL.g4 | 10 +- .../src/AntlrSQLQueryPlanCreator.cpp | 240 ++++++++++++++++++ 36 files changed, 2593 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqBoolTboolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTboolBoolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeBoolTboolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTboolBoolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqBoolTboolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTboolBoolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeBoolTboolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTboolBoolLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqBoolTboolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTboolBoolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeBoolTboolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTboolBoolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqBoolTboolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTboolBoolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeBoolTboolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTboolBoolLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqBoolTboolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTboolBoolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeBoolTboolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTboolBoolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqBoolTboolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTboolBoolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeBoolTboolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTboolBoolPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqBoolTboolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTboolBoolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeBoolTboolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTboolBoolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqBoolTboolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTboolBoolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeBoolTboolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTboolBoolPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqBoolTboolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqBoolTboolLogicalFunction.hpp new file mode 100644 index 0000000000..ef854f054f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqBoolTboolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_eq_bool_tbool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_eq_bool_tbool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysEqBoolTboolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqBoolTbool"; + + AlwaysEqBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTboolBoolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTboolBoolLogicalFunction.hpp new file mode 100644 index 0000000000..c3bab7ca57 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTboolBoolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_eq_tbool_bool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_eq_tbool_bool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysEqTboolBoolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTboolBool"; + + AlwaysEqTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeBoolTboolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeBoolTboolLogicalFunction.hpp new file mode 100644 index 0000000000..2be1fc26db --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeBoolTboolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ne_bool_tbool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ne_bool_tbool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysNeBoolTboolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeBoolTbool"; + + AlwaysNeBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTboolBoolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTboolBoolLogicalFunction.hpp new file mode 100644 index 0000000000..f743a7c66b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTboolBoolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ne_tbool_bool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ne_tbool_bool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysNeTboolBoolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTboolBool"; + + AlwaysNeTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqBoolTboolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqBoolTboolLogicalFunction.hpp new file mode 100644 index 0000000000..c0b490a099 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqBoolTboolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_eq_bool_tbool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_eq_bool_tbool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverEqBoolTboolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqBoolTbool"; + + EverEqBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTboolBoolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTboolBoolLogicalFunction.hpp new file mode 100644 index 0000000000..a313b66594 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTboolBoolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_eq_tbool_bool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_eq_tbool_bool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverEqTboolBoolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTboolBool"; + + EverEqTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeBoolTboolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeBoolTboolLogicalFunction.hpp new file mode 100644 index 0000000000..b77a9ea104 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeBoolTboolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ne_bool_tbool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ne_bool_tbool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverNeBoolTboolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeBoolTbool"; + + EverNeBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTboolBoolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTboolBoolLogicalFunction.hpp new file mode 100644 index 0000000000..07dca7e895 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTboolBoolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ne_tbool_bool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ne_tbool_bool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverNeTboolBoolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTboolBool"; + + EverNeTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqBoolTboolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqBoolTboolLogicalFunction.cpp new file mode 100644 index 0000000000..e2ffb93ddc --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqBoolTboolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqBoolTboolLogicalFunction::AlwaysEqBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqBoolTboolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqBoolTboolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqBoolTboolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqBoolTboolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysEqBoolTboolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqBoolTboolLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqBoolTboolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqBoolTboolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysEqBoolTboolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysEqBoolTboolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqBoolTboolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqBoolTboolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysEqBoolTboolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTboolBoolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTboolBoolLogicalFunction.cpp new file mode 100644 index 0000000000..ae786168cc --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTboolBoolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTboolBoolLogicalFunction::AlwaysEqTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqTboolBoolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTboolBoolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTboolBoolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTboolBoolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysEqTboolBoolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTboolBoolLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTboolBoolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTboolBoolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysEqTboolBoolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysEqTboolBoolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTboolBoolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqTboolBoolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysEqTboolBoolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeBoolTboolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeBoolTboolLogicalFunction.cpp new file mode 100644 index 0000000000..79d74af6b7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeBoolTboolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeBoolTboolLogicalFunction::AlwaysNeBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeBoolTboolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeBoolTboolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeBoolTboolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeBoolTboolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysNeBoolTboolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeBoolTboolLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeBoolTboolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeBoolTboolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysNeBoolTboolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysNeBoolTboolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeBoolTboolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeBoolTboolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysNeBoolTboolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTboolBoolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTboolBoolLogicalFunction.cpp new file mode 100644 index 0000000000..3849ef5051 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTboolBoolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTboolBoolLogicalFunction::AlwaysNeTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeTboolBoolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTboolBoolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTboolBoolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTboolBoolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysNeTboolBoolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTboolBoolLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTboolBoolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTboolBoolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysNeTboolBoolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysNeTboolBoolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTboolBoolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeTboolBoolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysNeTboolBoolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 09a8d54498..f9a47318c7 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -184,3 +184,11 @@ add_plugin(AlwaysGtBigintTbigint LogicalFunction nes-logical-operators AlwaysGtB add_plugin(AlwaysLeBigintTbigint LogicalFunction nes-logical-operators AlwaysLeBigintTbigintLogicalFunction.cpp) add_plugin(AlwaysLtBigintTbigint LogicalFunction nes-logical-operators AlwaysLtBigintTbigintLogicalFunction.cpp) add_plugin(AlwaysNeBigintTbigint LogicalFunction nes-logical-operators AlwaysNeBigintTbigintLogicalFunction.cpp) +add_plugin(EverEqTboolBool LogicalFunction nes-logical-operators EverEqTboolBoolLogicalFunction.cpp) +add_plugin(EverNeTboolBool LogicalFunction nes-logical-operators EverNeTboolBoolLogicalFunction.cpp) +add_plugin(EverEqBoolTbool LogicalFunction nes-logical-operators EverEqBoolTboolLogicalFunction.cpp) +add_plugin(EverNeBoolTbool LogicalFunction nes-logical-operators EverNeBoolTboolLogicalFunction.cpp) +add_plugin(AlwaysEqTboolBool LogicalFunction nes-logical-operators AlwaysEqTboolBoolLogicalFunction.cpp) +add_plugin(AlwaysNeTboolBool LogicalFunction nes-logical-operators AlwaysNeTboolBoolLogicalFunction.cpp) +add_plugin(AlwaysEqBoolTbool LogicalFunction nes-logical-operators AlwaysEqBoolTboolLogicalFunction.cpp) +add_plugin(AlwaysNeBoolTbool LogicalFunction nes-logical-operators AlwaysNeBoolTboolLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqBoolTboolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqBoolTboolLogicalFunction.cpp new file mode 100644 index 0000000000..dfe6ced0b7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqBoolTboolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqBoolTboolLogicalFunction::EverEqBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqBoolTboolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqBoolTboolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqBoolTboolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqBoolTboolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverEqBoolTboolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqBoolTboolLogicalFunction::getType() const { return NAME; } + +bool EverEqBoolTboolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqBoolTboolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverEqBoolTboolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverEqBoolTboolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqBoolTboolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqBoolTboolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverEqBoolTboolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTboolBoolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTboolBoolLogicalFunction.cpp new file mode 100644 index 0000000000..c47995fd5f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTboolBoolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTboolBoolLogicalFunction::EverEqTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqTboolBoolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTboolBoolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTboolBoolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTboolBoolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverEqTboolBoolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTboolBoolLogicalFunction::getType() const { return NAME; } + +bool EverEqTboolBoolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTboolBoolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverEqTboolBoolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverEqTboolBoolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTboolBoolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqTboolBoolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverEqTboolBoolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeBoolTboolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeBoolTboolLogicalFunction.cpp new file mode 100644 index 0000000000..97a13892b0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeBoolTboolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeBoolTboolLogicalFunction::EverNeBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeBoolTboolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeBoolTboolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeBoolTboolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeBoolTboolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverNeBoolTboolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeBoolTboolLogicalFunction::getType() const { return NAME; } + +bool EverNeBoolTboolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeBoolTboolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverNeBoolTboolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverNeBoolTboolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeBoolTboolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeBoolTboolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverNeBoolTboolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTboolBoolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTboolBoolLogicalFunction.cpp new file mode 100644 index 0000000000..a9bf43de76 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTboolBoolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTboolBoolLogicalFunction::EverNeTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeTboolBoolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTboolBoolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTboolBoolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTboolBoolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverNeTboolBoolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTboolBoolLogicalFunction::getType() const { return NAME; } + +bool EverNeTboolBoolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTboolBoolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverNeTboolBoolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverNeTboolBoolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTboolBoolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeTboolBoolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverNeTboolBoolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqBoolTboolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqBoolTboolPhysicalFunction.hpp new file mode 100644 index 0000000000..c98290da98 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqBoolTboolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_eq_bool_tbool`. + * + * Per-event always_eq_bool_tbool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysEqBoolTboolPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqBoolTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTboolBoolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTboolBoolPhysicalFunction.hpp new file mode 100644 index 0000000000..f3bfd249ad --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTboolBoolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_eq_tbool_bool`. + * + * Per-event always_eq_tbool_bool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysEqTboolBoolPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeBoolTboolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeBoolTboolPhysicalFunction.hpp new file mode 100644 index 0000000000..deb38a50f1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeBoolTboolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ne_bool_tbool`. + * + * Per-event always_ne_bool_tbool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysNeBoolTboolPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeBoolTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTboolBoolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTboolBoolPhysicalFunction.hpp new file mode 100644 index 0000000000..aa6c793541 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTboolBoolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ne_tbool_bool`. + * + * Per-event always_ne_tbool_bool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysNeTboolBoolPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqBoolTboolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqBoolTboolPhysicalFunction.hpp new file mode 100644 index 0000000000..f51a3d12b2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqBoolTboolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_eq_bool_tbool`. + * + * Per-event ever_eq_bool_tbool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverEqBoolTboolPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqBoolTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTboolBoolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTboolBoolPhysicalFunction.hpp new file mode 100644 index 0000000000..50715d2d12 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTboolBoolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_eq_tbool_bool`. + * + * Per-event ever_eq_tbool_bool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverEqTboolBoolPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeBoolTboolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeBoolTboolPhysicalFunction.hpp new file mode 100644 index 0000000000..bda9de3732 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeBoolTboolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ne_bool_tbool`. + * + * Per-event ever_ne_bool_tbool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverNeBoolTboolPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeBoolTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTboolBoolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTboolBoolPhysicalFunction.hpp new file mode 100644 index 0000000000..fb18c1610b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTboolBoolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ne_tbool_bool`. + * + * Per-event ever_ne_tbool_bool: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverNeTboolBoolPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqBoolTboolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqBoolTboolPhysicalFunction.cpp new file mode 100644 index 0000000000..58a56e62f0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqBoolTboolPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqBoolTboolPhysicalFunction::AlwaysEqBoolTboolPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqBoolTboolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double b, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_eq_bool_tbool(static_cast(b != 0.0), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqBoolTboolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqBoolTboolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysEqBoolTboolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTboolBoolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTboolBoolPhysicalFunction.cpp new file mode 100644 index 0000000000..c661e73b5a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTboolBoolPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTboolBoolPhysicalFunction::AlwaysEqTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqTboolBoolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double thr, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_eq_tbool_bool(temp, static_cast(thr != 0.0)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTboolBoolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqTboolBoolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysEqTboolBoolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeBoolTboolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeBoolTboolPhysicalFunction.cpp new file mode 100644 index 0000000000..b459fba06d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeBoolTboolPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeBoolTboolPhysicalFunction::AlwaysNeBoolTboolPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeBoolTboolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double b, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_ne_bool_tbool(static_cast(b != 0.0), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeBoolTboolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeBoolTboolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysNeBoolTboolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTboolBoolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTboolBoolPhysicalFunction.cpp new file mode 100644 index 0000000000..4d3b327a92 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTboolBoolPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTboolBoolPhysicalFunction::AlwaysNeTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeTboolBoolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double thr, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + int r = always_ne_tbool_bool(temp, static_cast(thr != 0.0)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTboolBoolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeTboolBoolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysNeTboolBoolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index bd3c465f90..7cab9483d8 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -183,4 +183,12 @@ add_plugin(AlwaysGtBigintTbigint PhysicalFunction nes-physical-operators AlwaysG add_plugin(AlwaysLeBigintTbigint PhysicalFunction nes-physical-operators AlwaysLeBigintTbigintPhysicalFunction.cpp) add_plugin(AlwaysLtBigintTbigint PhysicalFunction nes-physical-operators AlwaysLtBigintTbigintPhysicalFunction.cpp) add_plugin(AlwaysNeBigintTbigint PhysicalFunction nes-physical-operators AlwaysNeBigintTbigintPhysicalFunction.cpp) +add_plugin(EverEqTboolBool PhysicalFunction nes-physical-operators EverEqTboolBoolPhysicalFunction.cpp) +add_plugin(EverNeTboolBool PhysicalFunction nes-physical-operators EverNeTboolBoolPhysicalFunction.cpp) +add_plugin(AlwaysEqTboolBool PhysicalFunction nes-physical-operators AlwaysEqTboolBoolPhysicalFunction.cpp) +add_plugin(AlwaysNeTboolBool PhysicalFunction nes-physical-operators AlwaysNeTboolBoolPhysicalFunction.cpp) +add_plugin(EverEqBoolTbool PhysicalFunction nes-physical-operators EverEqBoolTboolPhysicalFunction.cpp) +add_plugin(EverNeBoolTbool PhysicalFunction nes-physical-operators EverNeBoolTboolPhysicalFunction.cpp) +add_plugin(AlwaysEqBoolTbool PhysicalFunction nes-physical-operators AlwaysEqBoolTboolPhysicalFunction.cpp) +add_plugin(AlwaysNeBoolTbool PhysicalFunction nes-physical-operators AlwaysNeBoolTboolPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/EverEqBoolTboolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqBoolTboolPhysicalFunction.cpp new file mode 100644 index 0000000000..2bcf7b5d88 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqBoolTboolPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqBoolTboolPhysicalFunction::EverEqBoolTboolPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverEqBoolTboolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double b, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_eq_bool_tbool(static_cast(b != 0.0), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqBoolTboolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqBoolTboolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverEqBoolTboolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTboolBoolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTboolBoolPhysicalFunction.cpp new file mode 100644 index 0000000000..b786054542 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTboolBoolPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTboolBoolPhysicalFunction::EverEqTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverEqTboolBoolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double thr, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_eq_tbool_bool(temp, static_cast(thr != 0.0)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTboolBoolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqTboolBoolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverEqTboolBoolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeBoolTboolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeBoolTboolPhysicalFunction.cpp new file mode 100644 index 0000000000..88fc83c45f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeBoolTboolPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeBoolTboolPhysicalFunction::EverNeBoolTboolPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverNeBoolTboolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double b, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_ne_bool_tbool(static_cast(b != 0.0), temp); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeBoolTboolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeBoolTboolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverNeBoolTboolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTboolBoolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTboolBoolPhysicalFunction.cpp new file mode 100644 index 0000000000..6002b94504 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTboolBoolPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTboolBoolPhysicalFunction::EverNeTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverNeTboolBoolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto threshold = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double thr, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + int r = ever_ne_tbool_bool(temp, static_cast(thr != 0.0)); + free(temp); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, threshold, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTboolBoolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeTboolBoolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverNeTboolBoolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 648ccc7e2c..ca13c40756 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -492,6 +492,8 @@ ALWAYS_GT_BIGINT_TBIGINT: 'ALWAYS_GT_BIGINT_TBIGINT' | 'always_gt_bigint_tbigint ALWAYS_LE_BIGINT_TBIGINT: 'ALWAYS_LE_BIGINT_TBIGINT' | 'always_le_bigint_tbigint'; ALWAYS_LT_BIGINT_TBIGINT: 'ALWAYS_LT_BIGINT_TBIGINT' | 'always_lt_bigint_tbigint'; ALWAYS_NE_BIGINT_TBIGINT: 'ALWAYS_NE_BIGINT_TBIGINT' | 'always_ne_bigint_tbigint'; +ALWAYS_EQ_BOOL_TBOOL: 'ALWAYS_EQ_BOOL_TBOOL' | 'always_eq_bool_tbool'; +ALWAYS_NE_BOOL_TBOOL: 'ALWAYS_NE_BOOL_TBOOL' | 'always_ne_bool_tbool'; ALWAYS_EQ_TBIGINT_BIGINT: 'ALWAYS_EQ_TBIGINT_BIGINT' | 'always_eq_tbigint_bigint'; ALWAYS_GE_TBIGINT_BIGINT: 'ALWAYS_GE_TBIGINT_BIGINT' | 'always_ge_tbigint_bigint'; ALWAYS_GT_TBIGINT_BIGINT: 'ALWAYS_GT_TBIGINT_BIGINT' | 'always_gt_tbigint_bigint'; @@ -504,6 +506,8 @@ ALWAYS_GT_TBIGINT_TBIGINT: 'ALWAYS_GT_TBIGINT_TBIGINT' | 'always_gt_tbigint_tbig ALWAYS_LE_TBIGINT_TBIGINT: 'ALWAYS_LE_TBIGINT_TBIGINT' | 'always_le_tbigint_tbigint'; ALWAYS_LT_TBIGINT_TBIGINT: 'ALWAYS_LT_TBIGINT_TBIGINT' | 'always_lt_tbigint_tbigint'; ALWAYS_NE_TBIGINT_TBIGINT: 'ALWAYS_NE_TBIGINT_TBIGINT' | 'always_ne_tbigint_tbigint'; +ALWAYS_EQ_TBOOL_BOOL: 'ALWAYS_EQ_TBOOL_BOOL' | 'always_eq_tbool_bool'; +ALWAYS_NE_TBOOL_BOOL: 'ALWAYS_NE_TBOOL_BOOL' | 'always_ne_tbool_bool'; ALWAYS_EQ_FLOAT_TFLOAT: 'ALWAYS_EQ_FLOAT_TFLOAT' | 'always_eq_float_tfloat'; ALWAYS_GE_FLOAT_TFLOAT: 'ALWAYS_GE_FLOAT_TFLOAT' | 'always_ge_float_tfloat'; ALWAYS_GT_FLOAT_TFLOAT: 'ALWAYS_GT_FLOAT_TFLOAT' | 'always_gt_float_tfloat'; @@ -547,6 +551,8 @@ EVER_GT_BIGINT_TBIGINT: 'EVER_GT_BIGINT_TBIGINT' | 'ever_gt_bigint_tbigint'; EVER_LE_BIGINT_TBIGINT: 'EVER_LE_BIGINT_TBIGINT' | 'ever_le_bigint_tbigint'; EVER_LT_BIGINT_TBIGINT: 'EVER_LT_BIGINT_TBIGINT' | 'ever_lt_bigint_tbigint'; EVER_NE_BIGINT_TBIGINT: 'EVER_NE_BIGINT_TBIGINT' | 'ever_ne_bigint_tbigint'; +EVER_EQ_BOOL_TBOOL: 'EVER_EQ_BOOL_TBOOL' | 'ever_eq_bool_tbool'; +EVER_NE_BOOL_TBOOL: 'EVER_NE_BOOL_TBOOL' | 'ever_ne_bool_tbool'; EVER_EQ_TBIGINT_BIGINT: 'EVER_EQ_TBIGINT_BIGINT' | 'ever_eq_tbigint_bigint'; EVER_GE_TBIGINT_BIGINT: 'EVER_GE_TBIGINT_BIGINT' | 'ever_ge_tbigint_bigint'; EVER_GT_TBIGINT_BIGINT: 'EVER_GT_TBIGINT_BIGINT' | 'ever_gt_tbigint_bigint'; @@ -559,6 +565,8 @@ EVER_GT_TBIGINT_TBIGINT: 'EVER_GT_TBIGINT_TBIGINT' | 'ever_gt_tbigint_tbigint'; EVER_LE_TBIGINT_TBIGINT: 'EVER_LE_TBIGINT_TBIGINT' | 'ever_le_tbigint_tbigint'; EVER_LT_TBIGINT_TBIGINT: 'EVER_LT_TBIGINT_TBIGINT' | 'ever_lt_tbigint_tbigint'; EVER_NE_TBIGINT_TBIGINT: 'EVER_NE_TBIGINT_TBIGINT' | 'ever_ne_tbigint_tbigint'; +EVER_EQ_TBOOL_BOOL: 'EVER_EQ_TBOOL_BOOL' | 'ever_eq_tbool_bool'; +EVER_NE_TBOOL_BOOL: 'EVER_NE_TBOOL_BOOL' | 'ever_ne_tbool_bool'; EVER_EQ_FLOAT_TFLOAT: 'EVER_EQ_FLOAT_TFLOAT' | 'ever_eq_float_tfloat'; EVER_GE_FLOAT_TFLOAT: 'EVER_GE_FLOAT_TFLOAT' | 'ever_ge_float_tfloat'; EVER_GT_FLOAT_TFLOAT: 'EVER_GT_FLOAT_TFLOAT' | 'ever_gt_float_tfloat'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index aa7d1263e5..fdf7771230 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -235,6 +235,14 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -3544,6 +3552,64 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: EVER_NE_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_BOOL_TBOOL */ + case AntlrSQLLexer::EVER_EQ_BOOL_TBOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_BOOL_TBOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqBoolTboolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_BOOL_TBOOL */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_BOOL_TBOOL */ + case AntlrSQLLexer::EVER_NE_BOOL_TBOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_BOOL_TBOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeBoolTboolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_NE_BOOL_TBOOL */ /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_FLOAT_TFLOAT */ case AntlrSQLLexer::EVER_EQ_FLOAT_TFLOAT: {{ @@ -3718,6 +3784,64 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont }} break; /* END CODEGEN PARSER GLUE: EVER_NE_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TBOOL_BOOL */ + case AntlrSQLLexer::EVER_EQ_TBOOL_BOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_TBOOL_BOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqTboolBoolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_TBOOL_BOOL */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_TBOOL_BOOL */ + case AntlrSQLLexer::EVER_NE_TBOOL_BOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_TBOOL_BOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeTboolBoolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_NE_TBOOL_BOOL */ /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::EVER_EQ_TFLOAT_FLOAT: { @@ -5632,6 +5756,64 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: ALWAYS_NE_TBIGINT_TBIGINT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_BOOL_TBOOL */ + case AntlrSQLLexer::ALWAYS_EQ_BOOL_TBOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_BOOL_TBOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqBoolTboolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_BOOL_TBOOL */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_BOOL_TBOOL */ + case AntlrSQLLexer::ALWAYS_NE_BOOL_TBOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_NE_BOOL_TBOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysNeBoolTboolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_NE_BOOL_TBOOL */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_FLOAT_TFLOAT */ case AntlrSQLLexer::ALWAYS_EQ_FLOAT_TFLOAT: {{ @@ -5806,6 +5988,64 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont }} break; /* END CODEGEN PARSER GLUE: ALWAYS_NE_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TBOOL_BOOL */ + case AntlrSQLLexer::ALWAYS_EQ_TBOOL_BOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_TBOOL_BOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqTboolBoolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TBOOL_BOOL */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_TBOOL_BOOL */ + case AntlrSQLLexer::ALWAYS_NE_TBOOL_BOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_NE_TBOOL_BOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysNeTboolBoolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TBOOL_BOOL */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 4dbc251fe8fc2341247f5ded993c11700fec67f6 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 10:28:50 +0200 Subject: [PATCH 33/86] feat(meos): add EVER/ALWAYS_{EQ,GE,GT,LE,LT,NE}_TEMPORAL_TEMPORAL NES operators (W83-W84) --- ...lwaysEqTemporalTemporalLogicalFunction.hpp | 54 +++ ...lwaysGeTemporalTemporalLogicalFunction.hpp | 54 +++ ...lwaysGtTemporalTemporalLogicalFunction.hpp | 54 +++ ...lwaysLeTemporalTemporalLogicalFunction.hpp | 54 +++ ...lwaysLtTemporalTemporalLogicalFunction.hpp | 54 +++ ...lwaysNeTemporalTemporalLogicalFunction.hpp | 54 +++ .../EverEqTemporalTemporalLogicalFunction.hpp | 54 +++ .../EverGeTemporalTemporalLogicalFunction.hpp | 54 +++ .../EverGtTemporalTemporalLogicalFunction.hpp | 54 +++ .../EverLeTemporalTemporalLogicalFunction.hpp | 54 +++ .../EverLtTemporalTemporalLogicalFunction.hpp | 54 +++ .../EverNeTemporalTemporalLogicalFunction.hpp | 54 +++ ...lwaysEqTemporalTemporalLogicalFunction.cpp | 105 +++++ ...lwaysGeTemporalTemporalLogicalFunction.cpp | 105 +++++ ...lwaysGtTemporalTemporalLogicalFunction.cpp | 105 +++++ ...lwaysLeTemporalTemporalLogicalFunction.cpp | 105 +++++ ...lwaysLtTemporalTemporalLogicalFunction.cpp | 105 +++++ ...lwaysNeTemporalTemporalLogicalFunction.cpp | 105 +++++ .../src/Functions/Meos/CMakeLists.txt | 12 + .../EverEqTemporalTemporalLogicalFunction.cpp | 105 +++++ .../EverGeTemporalTemporalLogicalFunction.cpp | 105 +++++ .../EverGtTemporalTemporalLogicalFunction.cpp | 105 +++++ .../EverLeTemporalTemporalLogicalFunction.cpp | 105 +++++ .../EverLtTemporalTemporalLogicalFunction.cpp | 105 +++++ .../EverNeTemporalTemporalLogicalFunction.cpp | 105 +++++ ...waysEqTemporalTemporalPhysicalFunction.hpp | 43 +++ ...waysGeTemporalTemporalPhysicalFunction.hpp | 43 +++ ...waysGtTemporalTemporalPhysicalFunction.hpp | 43 +++ ...waysLeTemporalTemporalPhysicalFunction.hpp | 43 +++ ...waysLtTemporalTemporalPhysicalFunction.hpp | 43 +++ ...waysNeTemporalTemporalPhysicalFunction.hpp | 43 +++ ...EverEqTemporalTemporalPhysicalFunction.hpp | 43 +++ ...EverGeTemporalTemporalPhysicalFunction.hpp | 43 +++ ...EverGtTemporalTemporalPhysicalFunction.hpp | 43 +++ ...EverLeTemporalTemporalPhysicalFunction.hpp | 43 +++ ...EverLtTemporalTemporalPhysicalFunction.hpp | 43 +++ ...EverNeTemporalTemporalPhysicalFunction.hpp | 43 +++ ...waysEqTemporalTemporalPhysicalFunction.cpp | 93 +++++ ...waysGeTemporalTemporalPhysicalFunction.cpp | 93 +++++ ...waysGtTemporalTemporalPhysicalFunction.cpp | 93 +++++ ...waysLeTemporalTemporalPhysicalFunction.cpp | 93 +++++ ...waysLtTemporalTemporalPhysicalFunction.cpp | 93 +++++ ...waysNeTemporalTemporalPhysicalFunction.cpp | 93 +++++ .../src/Functions/Meos/CMakeLists.txt | 12 + ...EverEqTemporalTemporalPhysicalFunction.cpp | 93 +++++ ...EverGeTemporalTemporalPhysicalFunction.cpp | 93 +++++ ...EverGtTemporalTemporalPhysicalFunction.cpp | 93 +++++ ...EverLeTemporalTemporalPhysicalFunction.cpp | 93 +++++ ...EverLtTemporalTemporalPhysicalFunction.cpp | 93 +++++ ...EverNeTemporalTemporalPhysicalFunction.cpp | 93 +++++ nes-sql-parser/AntlrSQL.g4 | 14 +- .../src/AntlrSQLQueryPlanCreator.cpp | 360 ++++++++++++++++++ 52 files changed, 3937 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGeTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGtTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLeTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLtTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGeTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGtTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLeTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLtTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGeTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGtTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLeTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLtTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGeTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGtTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLeTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLtTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTemporalTemporalLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGeTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGtTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLeTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLtTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGeTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGtTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLeTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLtTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGeTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGtTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLeTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLtTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGeTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGtTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLeTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLtTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTemporalTemporalPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..1119fd60d0 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_eq_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_eq_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysEqTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTemporalTemporal"; + + AlwaysEqTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..647c33addd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ge_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ge_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGeTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGeTemporalTemporal"; + + AlwaysGeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..a7362efb30 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_gt_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_gt_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysGtTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGtTemporalTemporal"; + + AlwaysGtTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..4cd15d1b1f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_le_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_le_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLeTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLeTemporalTemporal"; + + AlwaysLeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..7979f582d9 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_lt_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_lt_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysLtTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLtTemporalTemporal"; + + AlwaysLtTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..eb898a21e6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event always_ne_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `always_ne_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class AlwaysNeTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTemporalTemporal"; + + AlwaysNeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..eba432b62b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_eq_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_eq_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverEqTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTemporalTemporal"; + + EverEqTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGeTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..e871ad743d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGeTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ge_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ge_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGeTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGeTemporalTemporal"; + + EverGeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGtTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..8731c8a6a5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGtTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_gt_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_gt_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverGtTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGtTemporalTemporal"; + + EverGtTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLeTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..6463120db6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLeTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_le_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_le_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLeTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLeTemporalTemporal"; + + EverLeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLtTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..87f20d2867 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLtTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_lt_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_lt_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverLtTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLtTemporalTemporal"; + + EverLtTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..7cec67dbac --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ever_ne_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ever_ne_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class EverNeTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTemporalTemporal"; + + EverNeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..21b53dd08e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTemporalTemporalLogicalFunction::AlwaysEqTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysEqTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysEqTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysEqTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysEqTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..2a881ba8c9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGeTemporalTemporalLogicalFunction::AlwaysGeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGeTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGeTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGeTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGeTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGeTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGeTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool AlwaysGeTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGeTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGeTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGeTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGeTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGeTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..16169b2eac --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysGtTemporalTemporalLogicalFunction::AlwaysGtTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysGtTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGtTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysGtTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGtTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysGtTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysGtTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool AlwaysGtTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysGtTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysGtTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysGtTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysGtTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysGtTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..5e3005c912 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLeTemporalTemporalLogicalFunction::AlwaysLeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLeTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLeTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLeTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLeTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLeTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLeTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool AlwaysLeTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLeTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLeTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLeTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLeTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLeTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..b2cd2ba558 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysLtTemporalTemporalLogicalFunction::AlwaysLtTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysLtTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLtTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysLtTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLtTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysLtTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysLtTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool AlwaysLtTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysLtTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysLtTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysLtTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysLtTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysLtTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..f1d5e995f7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTemporalTemporalLogicalFunction::AlwaysNeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "AlwaysNeTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction AlwaysNeTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction AlwaysNeTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return AlwaysNeTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index f9a47318c7..f14f18a37c 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -192,3 +192,15 @@ add_plugin(AlwaysEqTboolBool LogicalFunction nes-logical-operators AlwaysEqTbool add_plugin(AlwaysNeTboolBool LogicalFunction nes-logical-operators AlwaysNeTboolBoolLogicalFunction.cpp) add_plugin(AlwaysEqBoolTbool LogicalFunction nes-logical-operators AlwaysEqBoolTboolLogicalFunction.cpp) add_plugin(AlwaysNeBoolTbool LogicalFunction nes-logical-operators AlwaysNeBoolTboolLogicalFunction.cpp) +add_plugin(EverEqTemporalTemporal LogicalFunction nes-logical-operators EverEqTemporalTemporalLogicalFunction.cpp) +add_plugin(EverGeTemporalTemporal LogicalFunction nes-logical-operators EverGeTemporalTemporalLogicalFunction.cpp) +add_plugin(EverGtTemporalTemporal LogicalFunction nes-logical-operators EverGtTemporalTemporalLogicalFunction.cpp) +add_plugin(EverLeTemporalTemporal LogicalFunction nes-logical-operators EverLeTemporalTemporalLogicalFunction.cpp) +add_plugin(EverLtTemporalTemporal LogicalFunction nes-logical-operators EverLtTemporalTemporalLogicalFunction.cpp) +add_plugin(EverNeTemporalTemporal LogicalFunction nes-logical-operators EverNeTemporalTemporalLogicalFunction.cpp) +add_plugin(AlwaysEqTemporalTemporal LogicalFunction nes-logical-operators AlwaysEqTemporalTemporalLogicalFunction.cpp) +add_plugin(AlwaysGeTemporalTemporal LogicalFunction nes-logical-operators AlwaysGeTemporalTemporalLogicalFunction.cpp) +add_plugin(AlwaysGtTemporalTemporal LogicalFunction nes-logical-operators AlwaysGtTemporalTemporalLogicalFunction.cpp) +add_plugin(AlwaysLeTemporalTemporal LogicalFunction nes-logical-operators AlwaysLeTemporalTemporalLogicalFunction.cpp) +add_plugin(AlwaysLtTemporalTemporal LogicalFunction nes-logical-operators AlwaysLtTemporalTemporalLogicalFunction.cpp) +add_plugin(AlwaysNeTemporalTemporal LogicalFunction nes-logical-operators AlwaysNeTemporalTemporalLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..93b07cb056 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTemporalTemporalLogicalFunction::EverEqTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverEqTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool EverEqTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverEqTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverEqTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverEqTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..5480aff699 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGeTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGeTemporalTemporalLogicalFunction::EverGeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGeTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGeTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGeTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGeTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGeTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGeTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool EverGeTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGeTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGeTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGeTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGeTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGeTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..ab18b264c2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGtTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverGtTemporalTemporalLogicalFunction::EverGtTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverGtTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGtTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverGtTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGtTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverGtTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverGtTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool EverGtTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverGtTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverGtTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverGtTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverGtTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverGtTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..14d8f2ccaa --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLeTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLeTemporalTemporalLogicalFunction::EverLeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLeTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLeTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLeTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLeTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLeTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLeTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool EverLeTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLeTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLeTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLeTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLeTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLeTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..93b8adbb06 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLtTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverLtTemporalTemporalLogicalFunction::EverLtTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverLtTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLtTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverLtTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLtTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverLtTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverLtTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool EverLtTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverLtTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverLtTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverLtTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverLtTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverLtTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..db5ae7e632 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTemporalTemporalLogicalFunction::EverNeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "EverNeTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool EverNeTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction EverNeTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction EverNeTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return EverNeTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..693c6f30a1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_eq_temporal_temporal`. + * + * Per-event always_eq_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysEqTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..9e8f9d6587 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ge_temporal_temporal`. + * + * Per-event always_ge_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGeTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGeTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..dab636c409 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_gt_temporal_temporal`. + * + * Per-event always_gt_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysGtTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGtTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..d5bfda04e0 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_le_temporal_temporal`. + * + * Per-event always_le_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLeTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLeTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..c735e0b348 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_lt_temporal_temporal`. + * + * Per-event always_lt_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysLtTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLtTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..748bad3b24 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `always_ne_temporal_temporal`. + * + * Per-event always_ne_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class AlwaysNeTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..6b9cf6ba58 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_eq_temporal_temporal`. + * + * Per-event ever_eq_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverEqTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGeTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..6106d2f3a9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGeTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ge_temporal_temporal`. + * + * Per-event ever_ge_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGeTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGeTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGtTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..44bf8ac0b5 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGtTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_gt_temporal_temporal`. + * + * Per-event ever_gt_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverGtTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGtTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLeTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..595864ba80 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLeTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_le_temporal_temporal`. + * + * Per-event ever_le_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLeTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLeTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLtTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..92fecbd859 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLtTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_lt_temporal_temporal`. + * + * Per-event ever_lt_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverLtTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLtTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..6c64b42b48 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `ever_ne_temporal_temporal`. + * + * Per-event ever_ne_temporal_temporal: tests if a single-instant tfloat value ever equals a threshold. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class EverNeTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..8761987aba --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTemporalTemporalPhysicalFunction::AlwaysEqTemporalTemporalPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_eq_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysEqTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..dcec06fad9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGeTemporalTemporalPhysicalFunction::AlwaysGeTemporalTemporalPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGeTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_ge_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGeTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGeTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGeTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..67ffaefc85 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysGtTemporalTemporalPhysicalFunction::AlwaysGtTemporalTemporalPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGtTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_gt_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGtTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGtTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysGtTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..7220089652 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLeTemporalTemporalPhysicalFunction::AlwaysLeTemporalTemporalPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLeTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_le_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLeTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLeTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLeTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..e1a743f20b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysLtTemporalTemporalPhysicalFunction::AlwaysLtTemporalTemporalPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLtTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_lt_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLtTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLtTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysLtTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..04d9aa9d38 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTemporalTemporalPhysicalFunction::AlwaysNeTemporalTemporalPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = always_ne_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return AlwaysNeTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 7cab9483d8..dc9e89ae77 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -191,4 +191,16 @@ add_plugin(EverEqBoolTbool PhysicalFunction nes-physical-operators EverEqBoolTbo add_plugin(EverNeBoolTbool PhysicalFunction nes-physical-operators EverNeBoolTboolPhysicalFunction.cpp) add_plugin(AlwaysEqBoolTbool PhysicalFunction nes-physical-operators AlwaysEqBoolTboolPhysicalFunction.cpp) add_plugin(AlwaysNeBoolTbool PhysicalFunction nes-physical-operators AlwaysNeBoolTboolPhysicalFunction.cpp) +add_plugin(EverEqTemporalTemporal PhysicalFunction nes-physical-operators EverEqTemporalTemporalPhysicalFunction.cpp) +add_plugin(EverGeTemporalTemporal PhysicalFunction nes-physical-operators EverGeTemporalTemporalPhysicalFunction.cpp) +add_plugin(EverGtTemporalTemporal PhysicalFunction nes-physical-operators EverGtTemporalTemporalPhysicalFunction.cpp) +add_plugin(EverLeTemporalTemporal PhysicalFunction nes-physical-operators EverLeTemporalTemporalPhysicalFunction.cpp) +add_plugin(EverLtTemporalTemporal PhysicalFunction nes-physical-operators EverLtTemporalTemporalPhysicalFunction.cpp) +add_plugin(EverNeTemporalTemporal PhysicalFunction nes-physical-operators EverNeTemporalTemporalPhysicalFunction.cpp) +add_plugin(AlwaysEqTemporalTemporal PhysicalFunction nes-physical-operators AlwaysEqTemporalTemporalPhysicalFunction.cpp) +add_plugin(AlwaysGeTemporalTemporal PhysicalFunction nes-physical-operators AlwaysGeTemporalTemporalPhysicalFunction.cpp) +add_plugin(AlwaysGtTemporalTemporal PhysicalFunction nes-physical-operators AlwaysGtTemporalTemporalPhysicalFunction.cpp) +add_plugin(AlwaysLeTemporalTemporal PhysicalFunction nes-physical-operators AlwaysLeTemporalTemporalPhysicalFunction.cpp) +add_plugin(AlwaysLtTemporalTemporal PhysicalFunction nes-physical-operators AlwaysLtTemporalTemporalPhysicalFunction.cpp) +add_plugin(AlwaysNeTemporalTemporal PhysicalFunction nes-physical-operators AlwaysNeTemporalTemporalPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..4415273e71 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTemporalTemporalPhysicalFunction::EverEqTemporalTemporalPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverEqTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_eq_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverEqTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGeTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..7d790039ad --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGeTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGeTemporalTemporalPhysicalFunction::EverGeTemporalTemporalPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGeTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_ge_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGeTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGeTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGeTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGtTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..381e050f79 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGtTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverGtTemporalTemporalPhysicalFunction::EverGtTemporalTemporalPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverGtTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_gt_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGtTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGtTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverGtTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLeTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..e7e3a8c02b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLeTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLeTemporalTemporalPhysicalFunction::EverLeTemporalTemporalPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLeTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_le_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLeTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLeTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLeTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLtTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..5255e0db4e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLtTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverLtTemporalTemporalPhysicalFunction::EverLtTemporalTemporalPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverLtTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_lt_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLtTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLtTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverLtTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..4162a14864 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTemporalTemporalPhysicalFunction::EverNeTemporalTemporalPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal EverNeTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", v1, ts_str); + std::string wkt2 = fmt::format("{}@{}", v2, ts_str); + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + int r = ever_ne_temporal_temporal(temp1, temp2); + free(temp1); + free(temp2); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return EverNeTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index ca13c40756..c9cf6273f7 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; sinkClause: INTO sink (',' sink)*; @@ -508,6 +508,12 @@ ALWAYS_LT_TBIGINT_TBIGINT: 'ALWAYS_LT_TBIGINT_TBIGINT' | 'always_lt_tbigint_tbig ALWAYS_NE_TBIGINT_TBIGINT: 'ALWAYS_NE_TBIGINT_TBIGINT' | 'always_ne_tbigint_tbigint'; ALWAYS_EQ_TBOOL_BOOL: 'ALWAYS_EQ_TBOOL_BOOL' | 'always_eq_tbool_bool'; ALWAYS_NE_TBOOL_BOOL: 'ALWAYS_NE_TBOOL_BOOL' | 'always_ne_tbool_bool'; +ALWAYS_EQ_TEMPORAL_TEMPORAL: 'ALWAYS_EQ_TEMPORAL_TEMPORAL' | 'always_eq_temporal_temporal'; +ALWAYS_GE_TEMPORAL_TEMPORAL: 'ALWAYS_GE_TEMPORAL_TEMPORAL' | 'always_ge_temporal_temporal'; +ALWAYS_GT_TEMPORAL_TEMPORAL: 'ALWAYS_GT_TEMPORAL_TEMPORAL' | 'always_gt_temporal_temporal'; +ALWAYS_LE_TEMPORAL_TEMPORAL: 'ALWAYS_LE_TEMPORAL_TEMPORAL' | 'always_le_temporal_temporal'; +ALWAYS_LT_TEMPORAL_TEMPORAL: 'ALWAYS_LT_TEMPORAL_TEMPORAL' | 'always_lt_temporal_temporal'; +ALWAYS_NE_TEMPORAL_TEMPORAL: 'ALWAYS_NE_TEMPORAL_TEMPORAL' | 'always_ne_temporal_temporal'; ALWAYS_EQ_FLOAT_TFLOAT: 'ALWAYS_EQ_FLOAT_TFLOAT' | 'always_eq_float_tfloat'; ALWAYS_GE_FLOAT_TFLOAT: 'ALWAYS_GE_FLOAT_TFLOAT' | 'always_ge_float_tfloat'; ALWAYS_GT_FLOAT_TFLOAT: 'ALWAYS_GT_FLOAT_TFLOAT' | 'always_gt_float_tfloat'; @@ -567,6 +573,12 @@ EVER_LT_TBIGINT_TBIGINT: 'EVER_LT_TBIGINT_TBIGINT' | 'ever_lt_tbigint_tbigint'; EVER_NE_TBIGINT_TBIGINT: 'EVER_NE_TBIGINT_TBIGINT' | 'ever_ne_tbigint_tbigint'; EVER_EQ_TBOOL_BOOL: 'EVER_EQ_TBOOL_BOOL' | 'ever_eq_tbool_bool'; EVER_NE_TBOOL_BOOL: 'EVER_NE_TBOOL_BOOL' | 'ever_ne_tbool_bool'; +EVER_EQ_TEMPORAL_TEMPORAL: 'EVER_EQ_TEMPORAL_TEMPORAL' | 'ever_eq_temporal_temporal'; +EVER_GE_TEMPORAL_TEMPORAL: 'EVER_GE_TEMPORAL_TEMPORAL' | 'ever_ge_temporal_temporal'; +EVER_GT_TEMPORAL_TEMPORAL: 'EVER_GT_TEMPORAL_TEMPORAL' | 'ever_gt_temporal_temporal'; +EVER_LE_TEMPORAL_TEMPORAL: 'EVER_LE_TEMPORAL_TEMPORAL' | 'ever_le_temporal_temporal'; +EVER_LT_TEMPORAL_TEMPORAL: 'EVER_LT_TEMPORAL_TEMPORAL' | 'ever_lt_temporal_temporal'; +EVER_NE_TEMPORAL_TEMPORAL: 'EVER_NE_TEMPORAL_TEMPORAL' | 'ever_ne_temporal_temporal'; EVER_EQ_FLOAT_TFLOAT: 'EVER_EQ_FLOAT_TFLOAT' | 'ever_eq_float_tfloat'; EVER_GE_FLOAT_TFLOAT: 'EVER_GE_FLOAT_TFLOAT' | 'ever_ge_float_tfloat'; EVER_GT_FLOAT_TFLOAT: 'EVER_GT_FLOAT_TFLOAT' | 'ever_gt_float_tfloat'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index fdf7771230..0efdee3342 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -243,6 +243,18 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -3842,6 +3854,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont }} break; /* END CODEGEN PARSER GLUE: EVER_NE_TBOOL_BOOL */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::EVER_EQ_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GE_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::EVER_GE_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GE_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGeTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_GE_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GT_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::EVER_GT_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GT_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGtTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_GT_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LE_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::EVER_LE_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LE_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLeTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_LE_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LT_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::EVER_LT_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LT_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLtTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_LT_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::EVER_NE_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: EVER_NE_TEMPORAL_TEMPORAL */ /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::EVER_EQ_TFLOAT_FLOAT: { @@ -6046,6 +6232,180 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont }} break; /* END CODEGEN PARSER GLUE: ALWAYS_NE_TBOOL_BOOL */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::ALWAYS_EQ_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GE_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::ALWAYS_GE_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GE_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGeTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GE_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GT_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::ALWAYS_GT_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GT_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGtTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GT_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LE_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::ALWAYS_LE_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LE_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLeTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LE_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LT_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::ALWAYS_LT_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LT_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLtTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LT_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::ALWAYS_NE_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_NE_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysNeTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TEMPORAL_TEMPORAL */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 8038f504f8681f541f7288b8e8c87efced76ec93 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 10:47:50 +0200 Subject: [PATCH 34/86] feat(meos): add TNOT_TBOOL, TAND_{BOOL_TBOOL,TBOOL_BOOL,TBOOL_TBOOL}, TOR_{BOOL_TBOOL,TBOOL_BOOL,TBOOL_TBOOL} NES operators (W85) --- .../Meos/TandBoolTboolLogicalFunction.hpp | 54 +++++ .../Meos/TandTboolBoolLogicalFunction.hpp | 54 +++++ .../Meos/TandTboolTboolLogicalFunction.hpp | 54 +++++ .../Meos/TnotTboolLogicalFunction.hpp | 53 +++++ .../Meos/TorBoolTboolLogicalFunction.hpp | 54 +++++ .../Meos/TorTboolBoolLogicalFunction.hpp | 54 +++++ .../Meos/TorTboolTboolLogicalFunction.hpp | 54 +++++ .../src/Functions/Meos/CMakeLists.txt | 7 + .../Meos/TandBoolTboolLogicalFunction.cpp | 105 +++++++++ .../Meos/TandTboolBoolLogicalFunction.cpp | 105 +++++++++ .../Meos/TandTboolTboolLogicalFunction.cpp | 105 +++++++++ .../Meos/TnotTboolLogicalFunction.cpp | 102 +++++++++ .../Meos/TorBoolTboolLogicalFunction.cpp | 105 +++++++++ .../Meos/TorTboolBoolLogicalFunction.cpp | 105 +++++++++ .../Meos/TorTboolTboolLogicalFunction.cpp | 105 +++++++++ .../Meos/TandBoolTboolPhysicalFunction.hpp | 43 ++++ .../Meos/TandTboolBoolPhysicalFunction.hpp | 43 ++++ .../Meos/TandTboolTboolPhysicalFunction.hpp | 43 ++++ .../Meos/TnotTboolPhysicalFunction.hpp | 42 ++++ .../Meos/TorBoolTboolPhysicalFunction.hpp | 43 ++++ .../Meos/TorTboolBoolPhysicalFunction.hpp | 43 ++++ .../Meos/TorTboolTboolPhysicalFunction.hpp | 43 ++++ .../src/Functions/Meos/CMakeLists.txt | 7 + .../Meos/TandBoolTboolPhysicalFunction.cpp | 92 ++++++++ .../Meos/TandTboolBoolPhysicalFunction.cpp | 92 ++++++++ .../Meos/TandTboolTboolPhysicalFunction.cpp | 95 ++++++++ .../Meos/TnotTboolPhysicalFunction.cpp | 88 ++++++++ .../Meos/TorBoolTboolPhysicalFunction.cpp | 92 ++++++++ .../Meos/TorTboolBoolPhysicalFunction.cpp | 92 ++++++++ .../Meos/TorTboolTboolPhysicalFunction.cpp | 95 ++++++++ nes-sql-parser/AntlrSQL.g4 | 9 +- .../src/AntlrSQLQueryPlanCreator.cpp | 209 ++++++++++++++++++ 32 files changed, 2286 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TandBoolTboolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TandTboolBoolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TandTboolTboolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TnotTboolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TorBoolTboolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TorTboolBoolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TorTboolTboolLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TandBoolTboolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TandTboolBoolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TandTboolTboolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TnotTboolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TorBoolTboolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TorTboolBoolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TorTboolTboolLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TandBoolTboolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TandTboolBoolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TandTboolTboolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TnotTboolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TorBoolTboolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TorTboolBoolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TorTboolTboolPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TandBoolTboolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TandTboolBoolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TandTboolTboolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TnotTboolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TorBoolTboolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TorTboolBoolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TorTboolTboolPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TandBoolTboolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TandBoolTboolLogicalFunction.hpp new file mode 100644 index 0000000000..eae9d72a0c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TandBoolTboolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tand_bool_tbool: AND of a scalar bool and a single-instant tbool. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tand_bool_tbool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the operation, and returns FLOAT64 (0.0/1.0). + */ +class TandBoolTboolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TandBoolTbool"; + + TandBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TandTboolBoolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TandTboolBoolLogicalFunction.hpp new file mode 100644 index 0000000000..f7e834a10a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TandTboolBoolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tand_tbool_bool: AND of a single-instant tbool and a scalar bool. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tand_tbool_bool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the operation, and returns FLOAT64 (0.0/1.0). + */ +class TandTboolBoolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TandTboolBool"; + + TandTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TandTboolTboolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TandTboolTboolLogicalFunction.hpp new file mode 100644 index 0000000000..1c5dd6679c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TandTboolTboolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tand_tbool_tbool: AND of two single-instant tbools. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tand_tbool_tbool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the operation, and returns FLOAT64 (0.0/1.0). + */ +class TandTboolTboolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TandTboolTbool"; + + TandTboolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TnotTboolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TnotTboolLogicalFunction.hpp new file mode 100644 index 0000000000..a9f99b5e4c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TnotTboolLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tnot_tbool: single-instant tbool negation, result extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tnot_tbool`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TnotTboolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TnotTbool"; + + TnotTboolLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TorBoolTboolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TorBoolTboolLogicalFunction.hpp new file mode 100644 index 0000000000..f1c8088610 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TorBoolTboolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tor_bool_tbool: OR of a scalar bool and a single-instant tbool. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tor_bool_tbool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the operation, and returns FLOAT64 (0.0/1.0). + */ +class TorBoolTboolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TorBoolTbool"; + + TorBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TorTboolBoolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TorTboolBoolLogicalFunction.hpp new file mode 100644 index 0000000000..423e040e7e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TorTboolBoolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tor_tbool_bool: OR of a single-instant tbool and a scalar bool. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tor_tbool_bool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the operation, and returns FLOAT64 (0.0/1.0). + */ +class TorTboolBoolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TorTboolBool"; + + TorTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TorTboolTboolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TorTboolTboolLogicalFunction.hpp new file mode 100644 index 0000000000..113d6fee9a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TorTboolTboolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tor_tbool_tbool: OR of two single-instant tbools. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tor_tbool_tbool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the operation, and returns FLOAT64 (0.0/1.0). + */ +class TorTboolTboolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TorTboolTbool"; + + TorTboolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index f14f18a37c..4f6015011d 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -204,3 +204,10 @@ add_plugin(AlwaysGtTemporalTemporal LogicalFunction nes-logical-operators Always add_plugin(AlwaysLeTemporalTemporal LogicalFunction nes-logical-operators AlwaysLeTemporalTemporalLogicalFunction.cpp) add_plugin(AlwaysLtTemporalTemporal LogicalFunction nes-logical-operators AlwaysLtTemporalTemporalLogicalFunction.cpp) add_plugin(AlwaysNeTemporalTemporal LogicalFunction nes-logical-operators AlwaysNeTemporalTemporalLogicalFunction.cpp) +add_plugin(TandBoolTbool LogicalFunction nes-logical-operators TandBoolTboolLogicalFunction.cpp) +add_plugin(TandTboolBool LogicalFunction nes-logical-operators TandTboolBoolLogicalFunction.cpp) +add_plugin(TandTboolTbool LogicalFunction nes-logical-operators TandTboolTboolLogicalFunction.cpp) +add_plugin(TnotTbool LogicalFunction nes-logical-operators TnotTboolLogicalFunction.cpp) +add_plugin(TorBoolTbool LogicalFunction nes-logical-operators TorBoolTboolLogicalFunction.cpp) +add_plugin(TorTboolBool LogicalFunction nes-logical-operators TorTboolBoolLogicalFunction.cpp) +add_plugin(TorTboolTbool LogicalFunction nes-logical-operators TorTboolTboolLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TandBoolTboolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TandBoolTboolLogicalFunction.cpp new file mode 100644 index 0000000000..fc0338db82 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TandBoolTboolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TandBoolTboolLogicalFunction::TandBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TandBoolTboolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TandBoolTboolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TandBoolTboolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TandBoolTboolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TandBoolTboolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TandBoolTboolLogicalFunction::getType() const { return NAME; } + +bool TandBoolTboolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TandBoolTboolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TandBoolTboolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TandBoolTboolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTandBoolTboolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TandBoolTboolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TandBoolTboolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TandTboolBoolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TandTboolBoolLogicalFunction.cpp new file mode 100644 index 0000000000..5e7300f734 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TandTboolBoolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TandTboolBoolLogicalFunction::TandTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TandTboolBoolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TandTboolBoolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TandTboolBoolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TandTboolBoolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TandTboolBoolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TandTboolBoolLogicalFunction::getType() const { return NAME; } + +bool TandTboolBoolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TandTboolBoolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TandTboolBoolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TandTboolBoolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTandTboolBoolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TandTboolBoolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TandTboolBoolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TandTboolTboolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TandTboolTboolLogicalFunction.cpp new file mode 100644 index 0000000000..c8023935d5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TandTboolTboolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TandTboolTboolLogicalFunction::TandTboolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TandTboolTboolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TandTboolTboolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TandTboolTboolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TandTboolTboolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TandTboolTboolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TandTboolTboolLogicalFunction::getType() const { return NAME; } + +bool TandTboolTboolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TandTboolTboolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TandTboolTboolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TandTboolTboolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTandTboolTboolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TandTboolTboolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TandTboolTboolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TnotTboolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TnotTboolLogicalFunction.cpp new file mode 100644 index 0000000000..91f7eb92e1 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TnotTboolLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TnotTboolLogicalFunction::TnotTboolLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TnotTboolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TnotTboolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TnotTboolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TnotTboolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TnotTboolLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TnotTboolLogicalFunction::getType() const { return NAME; } + +bool TnotTboolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TnotTboolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TnotTboolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TnotTboolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTnotTboolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TnotTboolLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TnotTboolLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TorBoolTboolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TorBoolTboolLogicalFunction.cpp new file mode 100644 index 0000000000..33d0326e8f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TorBoolTboolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TorBoolTboolLogicalFunction::TorBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TorBoolTboolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TorBoolTboolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TorBoolTboolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TorBoolTboolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TorBoolTboolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TorBoolTboolLogicalFunction::getType() const { return NAME; } + +bool TorBoolTboolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TorBoolTboolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TorBoolTboolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TorBoolTboolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTorBoolTboolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TorBoolTboolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TorBoolTboolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TorTboolBoolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TorTboolBoolLogicalFunction.cpp new file mode 100644 index 0000000000..f185e26c88 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TorTboolBoolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TorTboolBoolLogicalFunction::TorTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TorTboolBoolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TorTboolBoolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TorTboolBoolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TorTboolBoolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TorTboolBoolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TorTboolBoolLogicalFunction::getType() const { return NAME; } + +bool TorTboolBoolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TorTboolBoolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TorTboolBoolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TorTboolBoolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTorTboolBoolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TorTboolBoolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TorTboolBoolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TorTboolTboolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TorTboolTboolLogicalFunction.cpp new file mode 100644 index 0000000000..32f064daed --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TorTboolTboolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TorTboolTboolLogicalFunction::TorTboolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TorTboolTboolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TorTboolTboolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TorTboolTboolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TorTboolTboolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TorTboolTboolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TorTboolTboolLogicalFunction::getType() const { return NAME; } + +bool TorTboolTboolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TorTboolTboolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TorTboolTboolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TorTboolTboolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTorTboolTboolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TorTboolTboolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TorTboolTboolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TandBoolTboolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TandBoolTboolPhysicalFunction.hpp new file mode 100644 index 0000000000..541123f801 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TandBoolTboolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tand_bool_tbool`. + * + * Per-event tand_bool_tbool: AND of a scalar bool and a single-instant tbool. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TandBoolTboolPhysicalFunction : public PhysicalFunctionConcept { +public: + TandBoolTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TandTboolBoolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TandTboolBoolPhysicalFunction.hpp new file mode 100644 index 0000000000..e7227db724 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TandTboolBoolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tand_tbool_bool`. + * + * Per-event tand_tbool_bool: AND of a single-instant tbool and a scalar bool. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TandTboolBoolPhysicalFunction : public PhysicalFunctionConcept { +public: + TandTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TandTboolTboolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TandTboolTboolPhysicalFunction.hpp new file mode 100644 index 0000000000..cdbb608e49 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TandTboolTboolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tand_tbool_tbool`. + * + * Per-event tand_tbool_tbool: AND of two single-instant tbools. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TandTboolTboolPhysicalFunction : public PhysicalFunctionConcept { +public: + TandTboolTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TnotTboolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TnotTboolPhysicalFunction.hpp new file mode 100644 index 0000000000..6ef701368a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TnotTboolPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tnot_tbool`. + * + * Per-event tnot_tbool: single-instant tbool negation, result extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TnotTboolPhysicalFunction : public PhysicalFunctionConcept { +public: + TnotTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TorBoolTboolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TorBoolTboolPhysicalFunction.hpp new file mode 100644 index 0000000000..6f01525fca --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TorBoolTboolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tor_bool_tbool`. + * + * Per-event tor_bool_tbool: OR of a scalar bool and a single-instant tbool. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TorBoolTboolPhysicalFunction : public PhysicalFunctionConcept { +public: + TorBoolTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TorTboolBoolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TorTboolBoolPhysicalFunction.hpp new file mode 100644 index 0000000000..cc438a08e5 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TorTboolBoolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tor_tbool_bool`. + * + * Per-event tor_tbool_bool: OR of a single-instant tbool and a scalar bool. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TorTboolBoolPhysicalFunction : public PhysicalFunctionConcept { +public: + TorTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TorTboolTboolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TorTboolTboolPhysicalFunction.hpp new file mode 100644 index 0000000000..e7334cdad2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TorTboolTboolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tor_tbool_tbool`. + * + * Per-event tor_tbool_tbool: OR of two single-instant tbools. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TorTboolTboolPhysicalFunction : public PhysicalFunctionConcept { +public: + TorTboolTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index dc9e89ae77..be8913afa6 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -203,4 +203,11 @@ add_plugin(AlwaysGtTemporalTemporal PhysicalFunction nes-physical-operators Alwa add_plugin(AlwaysLeTemporalTemporal PhysicalFunction nes-physical-operators AlwaysLeTemporalTemporalPhysicalFunction.cpp) add_plugin(AlwaysLtTemporalTemporal PhysicalFunction nes-physical-operators AlwaysLtTemporalTemporalPhysicalFunction.cpp) add_plugin(AlwaysNeTemporalTemporal PhysicalFunction nes-physical-operators AlwaysNeTemporalTemporalPhysicalFunction.cpp) +add_plugin(TandBoolTbool PhysicalFunction nes-physical-operators TandBoolTboolPhysicalFunction.cpp) +add_plugin(TandTboolBool PhysicalFunction nes-physical-operators TandTboolBoolPhysicalFunction.cpp) +add_plugin(TandTboolTbool PhysicalFunction nes-physical-operators TandTboolTboolPhysicalFunction.cpp) +add_plugin(TnotTbool PhysicalFunction nes-physical-operators TnotTboolPhysicalFunction.cpp) +add_plugin(TorBoolTbool PhysicalFunction nes-physical-operators TorBoolTboolPhysicalFunction.cpp) +add_plugin(TorTboolBool PhysicalFunction nes-physical-operators TorTboolBoolPhysicalFunction.cpp) +add_plugin(TorTboolTbool PhysicalFunction nes-physical-operators TorTboolTboolPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TandBoolTboolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TandBoolTboolPhysicalFunction.cpp new file mode 100644 index 0000000000..16f0f24724 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TandBoolTboolPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TandBoolTboolPhysicalFunction::TandBoolTboolPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TandBoolTboolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double b, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tand_bool_tbool(static_cast(b != 0.0), temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTandBoolTboolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TandBoolTboolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TandBoolTboolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TandTboolBoolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TandTboolBoolPhysicalFunction.cpp new file mode 100644 index 0000000000..ef430d4016 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TandTboolBoolPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TandTboolBoolPhysicalFunction::TandTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction scalarFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TandTboolBoolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto scalar = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tand_tbool_bool(temp, static_cast(s != 0.0)); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, scalar, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTandTboolBoolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TandTboolBoolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TandTboolBoolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TandTboolTboolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TandTboolTboolPhysicalFunction.cpp new file mode 100644 index 0000000000..ec1c4beb98 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TandTboolTboolPhysicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TandTboolTboolPhysicalFunction::TandTboolTboolPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TandTboolTboolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", (v1 != 0.0 ? "t" : "f"), ts_str); + std::string wkt2 = fmt::format("{}@{}", (v2 != 0.0 ? "t" : "f"), ts_str); + Temporal* temp1 = tbool_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbool_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + Temporal* res = tand_tbool_tbool(temp1, temp2); + free(temp1); free(temp2); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTandTboolTboolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TandTboolTboolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TandTboolTboolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TnotTboolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TnotTboolPhysicalFunction.cpp new file mode 100644 index 0000000000..10c86464d8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TnotTboolPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TnotTboolPhysicalFunction::TnotTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TnotTboolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tnot_tbool(temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTnotTboolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TnotTboolPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TnotTboolPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TorBoolTboolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TorBoolTboolPhysicalFunction.cpp new file mode 100644 index 0000000000..dbf186f3ff --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TorBoolTboolPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TorBoolTboolPhysicalFunction::TorBoolTboolPhysicalFunction(PhysicalFunction scalarFunction, + PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TorBoolTboolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto scalar = parameterValues[0].cast>(); + auto value = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double b, double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tor_bool_tbool(static_cast(b != 0.0), temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + scalar, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTorBoolTboolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TorBoolTboolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TorBoolTboolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TorTboolBoolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TorTboolBoolPhysicalFunction.cpp new file mode 100644 index 0000000000..a39f01e2c7 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TorTboolBoolPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TorTboolBoolPhysicalFunction::TorTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction scalarFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(scalarFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TorTboolBoolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto scalar = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tor_tbool_bool(temp, static_cast(s != 0.0)); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, scalar, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTorTboolBoolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TorTboolBoolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TorTboolBoolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TorTboolTboolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TorTboolTboolPhysicalFunction.cpp new file mode 100644 index 0000000000..a27e8f674a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TorTboolTboolPhysicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TorTboolTboolPhysicalFunction::TorTboolTboolPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction value2Function, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(value1Function)); + parameterFunctions.push_back(std::move(value2Function)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TorTboolTboolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value1 = parameterValues[0].cast>(); + auto value2 = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v1, double v2, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}@{}", (v1 != 0.0 ? "t" : "f"), ts_str); + std::string wkt2 = fmt::format("{}@{}", (v2 != 0.0 ? "t" : "f"), ts_str); + Temporal* temp1 = tbool_in(wkt1.c_str()); + if (!temp1) return 0.0; + Temporal* temp2 = tbool_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + Temporal* res = tor_tbool_tbool(temp1, temp2); + free(temp1); free(temp2); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value1, value2, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTorTboolTboolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TorTboolTboolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TorTboolTboolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index c9cf6273f7..8352c429ae 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL; sinkClause: INTO sink (',' sink)*; @@ -674,6 +674,13 @@ TINT_SHIFT_VALUE: 'TINT_SHIFT_VALUE' | 'tint_shift_value'; TINT_TO_TBIGINT: 'TINT_TO_TBIGINT' | 'tint_to_tbigint'; TINT_TO_TFLOAT: 'TINT_TO_TFLOAT' | 'tint_to_tfloat'; TNUMBER_ABS: 'TNUMBER_ABS' | 'tnumber_abs'; +TAND_BOOL_TBOOL: 'TAND_BOOL_TBOOL' | 'tand_bool_tbool'; +TAND_TBOOL_BOOL: 'TAND_TBOOL_BOOL' | 'tand_tbool_bool'; +TAND_TBOOL_TBOOL: 'TAND_TBOOL_TBOOL' | 'tand_tbool_tbool'; +TNOT_TBOOL: 'TNOT_TBOOL' | 'tnot_tbool'; +TOR_BOOL_TBOOL: 'TOR_BOOL_TBOOL' | 'tor_bool_tbool'; +TOR_TBOOL_BOOL: 'TOR_TBOOL_BOOL' | 'tor_tbool_bool'; +TOR_TBOOL_TBOOL: 'TOR_TBOOL_TBOOL' | 'tor_tbool_tbool'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 0efdee3342..a16639422d 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -255,6 +255,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -6406,6 +6413,208 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont }} break; /* END CODEGEN PARSER GLUE: ALWAYS_NE_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: TNOT_TBOOL */ + case AntlrSQLLexer::TNOT_TBOOL: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TNOT_TBOOL requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TnotTboolLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TNOT_TBOOL */ + /* BEGIN CODEGEN PARSER GLUE: TAND_BOOL_TBOOL */ + case AntlrSQLLexer::TAND_BOOL_TBOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TAND_BOOL_TBOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TandBoolTboolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TAND_BOOL_TBOOL */ + /* BEGIN CODEGEN PARSER GLUE: TAND_TBOOL_BOOL */ + case AntlrSQLLexer::TAND_TBOOL_BOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TAND_TBOOL_BOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TandTboolBoolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TAND_TBOOL_BOOL */ + /* BEGIN CODEGEN PARSER GLUE: TAND_TBOOL_TBOOL */ + case AntlrSQLLexer::TAND_TBOOL_TBOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TAND_TBOOL_TBOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TandTboolTboolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TAND_TBOOL_TBOOL */ + /* BEGIN CODEGEN PARSER GLUE: TOR_BOOL_TBOOL */ + case AntlrSQLLexer::TOR_BOOL_TBOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TOR_BOOL_TBOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TorBoolTboolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TOR_BOOL_TBOOL */ + /* BEGIN CODEGEN PARSER GLUE: TOR_TBOOL_BOOL */ + case AntlrSQLLexer::TOR_TBOOL_BOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TOR_TBOOL_BOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TorTboolBoolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TOR_TBOOL_BOOL */ + /* BEGIN CODEGEN PARSER GLUE: TOR_TBOOL_TBOOL */ + case AntlrSQLLexer::TOR_TBOOL_TBOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TOR_TBOOL_TBOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TorTboolTboolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TOR_TBOOL_TBOOL */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 6ce1e63b4eefbf692e620af19f13b3d387b21e8d Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 10:52:38 +0200 Subject: [PATCH 35/86] feat(meos): add TEQ_{BOOL_TBOOL,TBOOL_BOOL,FLOAT_TFLOAT,TFLOAT_FLOAT,INT_TINT,TINT_INT,TEMPORAL_TEMPORAL} NES operators (W86) --- .../Meos/TeqBoolTboolLogicalFunction.hpp | 54 +++++ .../Meos/TeqFloatTfloatLogicalFunction.hpp | 54 +++++ .../Meos/TeqIntTintLogicalFunction.hpp | 54 +++++ .../Meos/TeqTboolBoolLogicalFunction.hpp | 54 +++++ .../TeqTemporalTemporalLogicalFunction.hpp | 54 +++++ .../Meos/TeqTfloatFloatLogicalFunction.hpp | 54 +++++ .../Meos/TeqTintIntLogicalFunction.hpp | 54 +++++ .../src/Functions/Meos/CMakeLists.txt | 7 + .../Meos/TeqBoolTboolLogicalFunction.cpp | 105 +++++++++ .../Meos/TeqFloatTfloatLogicalFunction.cpp | 105 +++++++++ .../Meos/TeqIntTintLogicalFunction.cpp | 105 +++++++++ .../Meos/TeqTboolBoolLogicalFunction.cpp | 105 +++++++++ .../TeqTemporalTemporalLogicalFunction.cpp | 105 +++++++++ .../Meos/TeqTfloatFloatLogicalFunction.cpp | 105 +++++++++ .../Meos/TeqTintIntLogicalFunction.cpp | 105 +++++++++ .../Meos/TeqBoolTboolPhysicalFunction.hpp | 43 ++++ .../Meos/TeqFloatTfloatPhysicalFunction.hpp | 43 ++++ .../Meos/TeqIntTintPhysicalFunction.hpp | 43 ++++ .../Meos/TeqTboolBoolPhysicalFunction.hpp | 43 ++++ .../TeqTemporalTemporalPhysicalFunction.hpp | 43 ++++ .../Meos/TeqTfloatFloatPhysicalFunction.hpp | 43 ++++ .../Meos/TeqTintIntPhysicalFunction.hpp | 43 ++++ .../src/Functions/Meos/CMakeLists.txt | 7 + .../Meos/TeqBoolTboolPhysicalFunction.cpp | 93 ++++++++ .../Meos/TeqFloatTfloatPhysicalFunction.cpp | 92 ++++++++ .../Meos/TeqIntTintPhysicalFunction.cpp | 93 ++++++++ .../Meos/TeqTboolBoolPhysicalFunction.cpp | 93 ++++++++ .../TeqTemporalTemporalPhysicalFunction.cpp | 95 ++++++++ .../Meos/TeqTfloatFloatPhysicalFunction.cpp | 92 ++++++++ .../Meos/TeqTintIntPhysicalFunction.cpp | 93 ++++++++ nes-sql-parser/AntlrSQL.g4 | 9 +- .../src/AntlrSQLQueryPlanCreator.cpp | 210 ++++++++++++++++++ 32 files changed, 2297 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TeqBoolTboolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TeqFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TeqIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TeqTboolBoolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TeqTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TeqTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TeqTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TeqBoolTboolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TeqFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TeqIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TeqTboolBoolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TeqTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TeqTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TeqTintIntLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TeqBoolTboolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TeqFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TeqIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TeqTboolBoolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TeqTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TeqTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TeqTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TeqBoolTboolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TeqFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TeqIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TeqTboolBoolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TeqTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TeqTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TeqTintIntPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TeqBoolTboolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TeqBoolTboolLogicalFunction.hpp new file mode 100644 index 0000000000..883d67de55 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TeqBoolTboolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal EQ: scalar bool vs single-instant tbool + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `teq_bool_tbool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TeqBoolTboolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TeqBoolTbool"; + + TeqBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TeqFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TeqFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..c6112cca24 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TeqFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal EQ: scalar float vs single-instant tfloat + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `teq_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TeqFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TeqFloatTfloat"; + + TeqFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TeqIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TeqIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..345185f526 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TeqIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal EQ: scalar int vs single-instant tint + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `teq_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TeqIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TeqIntTint"; + + TeqIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TeqTboolBoolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TeqTboolBoolLogicalFunction.hpp new file mode 100644 index 0000000000..af9a60f4df --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TeqTboolBoolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal EQ: single-instant tbool vs scalar bool + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `teq_tbool_bool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TeqTboolBoolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TeqTboolBool"; + + TeqTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TeqTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TeqTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..d1e518268a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TeqTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal EQ: two single-instant tfloats + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `teq_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TeqTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TeqTemporalTemporal"; + + TeqTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TeqTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TeqTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..6716163be2 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TeqTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal EQ: single-instant tfloat vs scalar float + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `teq_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TeqTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TeqTfloatFloat"; + + TeqTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TeqTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TeqTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..584f3b5784 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TeqTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal EQ: single-instant tint vs scalar int + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `teq_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TeqTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TeqTintInt"; + + TeqTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 4f6015011d..9a3d850eea 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -211,3 +211,10 @@ add_plugin(TnotTbool LogicalFunction nes-logical-operators TnotTboolLogicalFunct add_plugin(TorBoolTbool LogicalFunction nes-logical-operators TorBoolTboolLogicalFunction.cpp) add_plugin(TorTboolBool LogicalFunction nes-logical-operators TorTboolBoolLogicalFunction.cpp) add_plugin(TorTboolTbool LogicalFunction nes-logical-operators TorTboolTboolLogicalFunction.cpp) +add_plugin(TeqBoolTbool LogicalFunction nes-logical-operators TeqBoolTboolLogicalFunction.cpp) +add_plugin(TeqFloatTfloat LogicalFunction nes-logical-operators TeqFloatTfloatLogicalFunction.cpp) +add_plugin(TeqIntTint LogicalFunction nes-logical-operators TeqIntTintLogicalFunction.cpp) +add_plugin(TeqTboolBool LogicalFunction nes-logical-operators TeqTboolBoolLogicalFunction.cpp) +add_plugin(TeqTemporalTemporal LogicalFunction nes-logical-operators TeqTemporalTemporalLogicalFunction.cpp) +add_plugin(TeqTfloatFloat LogicalFunction nes-logical-operators TeqTfloatFloatLogicalFunction.cpp) +add_plugin(TeqTintInt LogicalFunction nes-logical-operators TeqTintIntLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TeqBoolTboolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TeqBoolTboolLogicalFunction.cpp new file mode 100644 index 0000000000..96ca3ab52f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TeqBoolTboolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TeqBoolTboolLogicalFunction::TeqBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TeqBoolTboolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TeqBoolTboolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TeqBoolTboolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TeqBoolTboolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TeqBoolTboolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TeqBoolTboolLogicalFunction::getType() const { return NAME; } + +bool TeqBoolTboolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TeqBoolTboolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TeqBoolTboolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TeqBoolTboolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTeqBoolTboolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TeqBoolTboolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TeqBoolTboolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TeqFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TeqFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..146580ca03 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TeqFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TeqFloatTfloatLogicalFunction::TeqFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TeqFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TeqFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TeqFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TeqFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TeqFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TeqFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool TeqFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TeqFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TeqFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TeqFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTeqFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TeqFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TeqFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TeqIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TeqIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..2dff635453 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TeqIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TeqIntTintLogicalFunction::TeqIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TeqIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TeqIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TeqIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TeqIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TeqIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TeqIntTintLogicalFunction::getType() const { return NAME; } + +bool TeqIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TeqIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TeqIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TeqIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTeqIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TeqIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TeqIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TeqTboolBoolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TeqTboolBoolLogicalFunction.cpp new file mode 100644 index 0000000000..f0fb48a313 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TeqTboolBoolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TeqTboolBoolLogicalFunction::TeqTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TeqTboolBoolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TeqTboolBoolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TeqTboolBoolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TeqTboolBoolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TeqTboolBoolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TeqTboolBoolLogicalFunction::getType() const { return NAME; } + +bool TeqTboolBoolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TeqTboolBoolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TeqTboolBoolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TeqTboolBoolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTeqTboolBoolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TeqTboolBoolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TeqTboolBoolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TeqTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TeqTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..7a9473659e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TeqTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TeqTemporalTemporalLogicalFunction::TeqTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TeqTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TeqTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TeqTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TeqTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TeqTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TeqTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool TeqTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TeqTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TeqTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TeqTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTeqTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TeqTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TeqTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TeqTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TeqTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..96d07075e3 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TeqTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TeqTfloatFloatLogicalFunction::TeqTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TeqTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TeqTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TeqTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TeqTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TeqTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TeqTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool TeqTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TeqTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TeqTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TeqTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTeqTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TeqTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TeqTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TeqTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TeqTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..6de831d63c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TeqTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TeqTintIntLogicalFunction::TeqTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TeqTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TeqTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TeqTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TeqTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TeqTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TeqTintIntLogicalFunction::getType() const { return NAME; } + +bool TeqTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TeqTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TeqTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TeqTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTeqTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TeqTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TeqTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TeqBoolTboolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TeqBoolTboolPhysicalFunction.hpp new file mode 100644 index 0000000000..ef746e752b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TeqBoolTboolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `teq_bool_tbool`. + * + * temporal EQ: scalar bool vs single-instant tbool + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TeqBoolTboolPhysicalFunction : public PhysicalFunctionConcept { +public: + TeqBoolTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TeqFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TeqFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..828a0eef12 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TeqFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `teq_float_tfloat`. + * + * temporal EQ: scalar float vs single-instant tfloat + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TeqFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TeqFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TeqIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TeqIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..25cef38b59 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TeqIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `teq_int_tint`. + * + * temporal EQ: scalar int vs single-instant tint + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TeqIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + TeqIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TeqTboolBoolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TeqTboolBoolPhysicalFunction.hpp new file mode 100644 index 0000000000..80a2c14469 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TeqTboolBoolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `teq_tbool_bool`. + * + * temporal EQ: single-instant tbool vs scalar bool + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TeqTboolBoolPhysicalFunction : public PhysicalFunctionConcept { +public: + TeqTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TeqTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TeqTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..1561f021ec --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TeqTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `teq_temporal_temporal`. + * + * temporal EQ: two single-instant tfloats + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TeqTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + TeqTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TeqTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TeqTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..e74ffd19bf --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TeqTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `teq_tfloat_float`. + * + * temporal EQ: single-instant tfloat vs scalar float + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TeqTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TeqTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TeqTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TeqTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..c0e86313c6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TeqTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `teq_tint_int`. + * + * temporal EQ: single-instant tint vs scalar int + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TeqTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + TeqTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index be8913afa6..5005e9d8b2 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -210,4 +210,11 @@ add_plugin(TnotTbool PhysicalFunction nes-physical-operators TnotTboolPhysicalFu add_plugin(TorBoolTbool PhysicalFunction nes-physical-operators TorBoolTboolPhysicalFunction.cpp) add_plugin(TorTboolBool PhysicalFunction nes-physical-operators TorTboolBoolPhysicalFunction.cpp) add_plugin(TorTboolTbool PhysicalFunction nes-physical-operators TorTboolTboolPhysicalFunction.cpp) +add_plugin(TeqBoolTbool PhysicalFunction nes-physical-operators TeqBoolTboolPhysicalFunction.cpp) +add_plugin(TeqFloatTfloat PhysicalFunction nes-physical-operators TeqFloatTfloatPhysicalFunction.cpp) +add_plugin(TeqIntTint PhysicalFunction nes-physical-operators TeqIntTintPhysicalFunction.cpp) +add_plugin(TeqTboolBool PhysicalFunction nes-physical-operators TeqTboolBoolPhysicalFunction.cpp) +add_plugin(TeqTemporalTemporal PhysicalFunction nes-physical-operators TeqTemporalTemporalPhysicalFunction.cpp) +add_plugin(TeqTfloatFloat PhysicalFunction nes-physical-operators TeqTfloatFloatPhysicalFunction.cpp) +add_plugin(TeqTintInt PhysicalFunction nes-physical-operators TeqTintIntPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TeqBoolTboolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TeqBoolTboolPhysicalFunction.cpp new file mode 100644 index 0000000000..5b46a75014 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TeqBoolTboolPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TeqBoolTboolPhysicalFunction::TeqBoolTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TeqBoolTboolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + bool sv = (v != 0.0); + std::string wkt = fmt::format("{}", (s != 0.0 ? "t" : "f")) + "@" + ts_str; + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = teq_bool_tbool(sv, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTeqBoolTboolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TeqBoolTboolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TeqBoolTboolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TeqFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TeqFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..68f66f7508 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TeqFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TeqFloatTfloatPhysicalFunction::TeqFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TeqFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", s) + "@" + ts_str; + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = teq_float_tfloat(v, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTeqFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TeqFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TeqFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TeqIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TeqIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..43a46c5389 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TeqIntTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TeqIntTintPhysicalFunction::TeqIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TeqIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + int iv = static_cast(v); + std::string wkt = fmt::format("{}", static_cast(s)) + "@" + ts_str; + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = teq_int_tint(iv, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTeqIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TeqIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TeqIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TeqTboolBoolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TeqTboolBoolPhysicalFunction.cpp new file mode 100644 index 0000000000..71041e3dc8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TeqTboolBoolPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TeqTboolBoolPhysicalFunction::TeqTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TeqTboolBoolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", (v != 0.0 ? "t" : "f")) + "@" + ts_str; + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + bool sv = (s != 0.0); + Temporal* res = teq_tbool_bool(temp, sv); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTeqTboolBoolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TeqTboolBoolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TeqTboolBoolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TeqTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TeqTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..2ebffbcfb4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TeqTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TeqTemporalTemporalPhysicalFunction::TeqTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TeqTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}", v) + "@" + ts_str; + Temporal* temp = tfloat_in(wkt1.c_str()); + if (!temp) return 0.0; + std::string wkt2 = fmt::format("{}", s) + "@" + ts_str; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp); return 0.0; } + Temporal* res = teq_temporal_temporal(temp, temp2); + free(temp); free(temp2); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTeqTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TeqTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TeqTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TeqTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TeqTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..d599cc0a6c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TeqTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TeqTfloatFloatPhysicalFunction::TeqTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TeqTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", v) + "@" + ts_str; + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = teq_tfloat_float(temp, s); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTeqTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TeqTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TeqTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TeqTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TeqTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..b2ead9a552 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TeqTintIntPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TeqTintIntPhysicalFunction::TeqTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TeqTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", static_cast(v)) + "@" + ts_str; + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int iv = static_cast(s); + Temporal* res = teq_tint_int(temp, iv); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTeqTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TeqTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TeqTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 8352c429ae..0fcbd50d39 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT; sinkClause: INTO sink (',' sink)*; @@ -681,6 +681,13 @@ TNOT_TBOOL: 'TNOT_TBOOL' | 'tnot_tbool'; TOR_BOOL_TBOOL: 'TOR_BOOL_TBOOL' | 'tor_bool_tbool'; TOR_TBOOL_BOOL: 'TOR_TBOOL_BOOL' | 'tor_tbool_bool'; TOR_TBOOL_TBOOL: 'TOR_TBOOL_TBOOL' | 'tor_tbool_tbool'; +TEQ_BOOL_TBOOL: 'TEQ_BOOL_TBOOL' | 'teq_bool_tbool'; +TEQ_FLOAT_TFLOAT: 'TEQ_FLOAT_TFLOAT' | 'teq_float_tfloat'; +TEQ_INT_TINT: 'TEQ_INT_TINT' | 'teq_int_tint'; +TEQ_TBOOL_BOOL: 'TEQ_TBOOL_BOOL' | 'teq_tbool_bool'; +TEQ_TEMPORAL_TEMPORAL: 'TEQ_TEMPORAL_TEMPORAL' | 'teq_temporal_temporal'; +TEQ_TFLOAT_FLOAT: 'TEQ_TFLOAT_FLOAT' | 'teq_tfloat_float'; +TEQ_TINT_INT: 'TEQ_TINT_INT' | 'teq_tint_int'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index a16639422d..ead24af3c4 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -262,6 +262,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -6615,6 +6622,209 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont }} break; /* END CODEGEN PARSER GLUE: TOR_TBOOL_TBOOL */ + /* BEGIN CODEGEN PARSER GLUE: TEQ_BOOL_TBOOL */ + case AntlrSQLLexer::TEQ_BOOL_TBOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TEQ_BOOL_TBOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TeqBoolTboolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TEQ_BOOL_TBOOL */ + /* BEGIN CODEGEN PARSER GLUE: TEQ_FLOAT_TFLOAT */ + case AntlrSQLLexer::TEQ_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TEQ_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TeqFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TEQ_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TEQ_INT_TINT */ + case AntlrSQLLexer::TEQ_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TEQ_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TeqIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TEQ_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: TEQ_TBOOL_BOOL */ + case AntlrSQLLexer::TEQ_TBOOL_BOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TEQ_TBOOL_BOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TeqTboolBoolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TEQ_TBOOL_BOOL */ + /* BEGIN CODEGEN PARSER GLUE: TEQ_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::TEQ_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TEQ_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TeqTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TEQ_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: TEQ_TFLOAT_FLOAT */ + case AntlrSQLLexer::TEQ_TFLOAT_FLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TEQ_TFLOAT_FLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TeqTfloatFloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TEQ_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TEQ_TINT_INT */ + case AntlrSQLLexer::TEQ_TINT_INT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TEQ_TINT_INT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TeqTintIntLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TEQ_TINT_INT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From a704037e68a30edd8460e33fddd9a94de9b2758d Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 10:57:04 +0200 Subject: [PATCH 36/86] feat(meos): add TNE_{BOOL_TBOOL,TBOOL_BOOL,FLOAT_TFLOAT,TFLOAT_FLOAT,INT_TINT,TINT_INT,TEMPORAL_TEMPORAL} NES operators (W87) --- .../Meos/TneBoolTboolLogicalFunction.hpp | 54 +++++ .../Meos/TneFloatTfloatLogicalFunction.hpp | 54 +++++ .../Meos/TneIntTintLogicalFunction.hpp | 54 +++++ .../Meos/TneTboolBoolLogicalFunction.hpp | 54 +++++ .../TneTemporalTemporalLogicalFunction.hpp | 54 +++++ .../Meos/TneTfloatFloatLogicalFunction.hpp | 54 +++++ .../Meos/TneTintIntLogicalFunction.hpp | 54 +++++ .../src/Functions/Meos/CMakeLists.txt | 7 + .../Meos/TneBoolTboolLogicalFunction.cpp | 105 +++++++++ .../Meos/TneFloatTfloatLogicalFunction.cpp | 105 +++++++++ .../Meos/TneIntTintLogicalFunction.cpp | 105 +++++++++ .../Meos/TneTboolBoolLogicalFunction.cpp | 105 +++++++++ .../TneTemporalTemporalLogicalFunction.cpp | 105 +++++++++ .../Meos/TneTfloatFloatLogicalFunction.cpp | 105 +++++++++ .../Meos/TneTintIntLogicalFunction.cpp | 105 +++++++++ .../Meos/TneBoolTboolPhysicalFunction.hpp | 43 ++++ .../Meos/TneFloatTfloatPhysicalFunction.hpp | 43 ++++ .../Meos/TneIntTintPhysicalFunction.hpp | 43 ++++ .../Meos/TneTboolBoolPhysicalFunction.hpp | 43 ++++ .../TneTemporalTemporalPhysicalFunction.hpp | 43 ++++ .../Meos/TneTfloatFloatPhysicalFunction.hpp | 43 ++++ .../Meos/TneTintIntPhysicalFunction.hpp | 43 ++++ .../src/Functions/Meos/CMakeLists.txt | 7 + .../Meos/TneBoolTboolPhysicalFunction.cpp | 93 ++++++++ .../Meos/TneFloatTfloatPhysicalFunction.cpp | 92 ++++++++ .../Meos/TneIntTintPhysicalFunction.cpp | 93 ++++++++ .../Meos/TneTboolBoolPhysicalFunction.cpp | 93 ++++++++ .../TneTemporalTemporalPhysicalFunction.cpp | 95 ++++++++ .../Meos/TneTfloatFloatPhysicalFunction.cpp | 92 ++++++++ .../Meos/TneTintIntPhysicalFunction.cpp | 93 ++++++++ nes-sql-parser/AntlrSQL.g4 | 9 +- .../src/AntlrSQLQueryPlanCreator.cpp | 210 ++++++++++++++++++ 32 files changed, 2297 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TneBoolTboolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TneFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TneIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TneTboolBoolLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TneTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TneTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TneTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TneBoolTboolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TneFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TneIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TneTboolBoolLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TneTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TneTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TneTintIntLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TneBoolTboolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TneFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TneIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TneTboolBoolPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TneTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TneTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TneTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TneBoolTboolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TneFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TneIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TneTboolBoolPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TneTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TneTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TneTintIntPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TneBoolTboolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TneBoolTboolLogicalFunction.hpp new file mode 100644 index 0000000000..1de3118a9e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TneBoolTboolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal NE: scalar bool vs single-instant tbool + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tne_bool_tbool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TneBoolTboolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TneBoolTbool"; + + TneBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TneFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TneFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..5cdae702ce --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TneFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal NE: scalar float vs single-instant tfloat + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tne_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TneFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TneFloatTfloat"; + + TneFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TneIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TneIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..9cbf66a925 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TneIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal NE: scalar int vs single-instant tint + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tne_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TneIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TneIntTint"; + + TneIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TneTboolBoolLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TneTboolBoolLogicalFunction.hpp new file mode 100644 index 0000000000..2414c7ca98 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TneTboolBoolLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal NE: single-instant tbool vs scalar bool + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tne_tbool_bool`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TneTboolBoolLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TneTboolBool"; + + TneTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TneTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TneTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..3e93e4a1b0 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TneTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal NE: two single-instant tfloats + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tne_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TneTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TneTemporalTemporal"; + + TneTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TneTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TneTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..e78377ecda --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TneTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal NE: single-instant tfloat vs scalar float + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tne_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TneTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TneTfloatFloat"; + + TneTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TneTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TneTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..e938a4313b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TneTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal NE: single-instant tint vs scalar int + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tne_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TneTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TneTintInt"; + + TneTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 9a3d850eea..72afd241e5 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -218,3 +218,10 @@ add_plugin(TeqTboolBool LogicalFunction nes-logical-operators TeqTboolBoolLogica add_plugin(TeqTemporalTemporal LogicalFunction nes-logical-operators TeqTemporalTemporalLogicalFunction.cpp) add_plugin(TeqTfloatFloat LogicalFunction nes-logical-operators TeqTfloatFloatLogicalFunction.cpp) add_plugin(TeqTintInt LogicalFunction nes-logical-operators TeqTintIntLogicalFunction.cpp) +add_plugin(TneTboolBool LogicalFunction nes-logical-operators TneTboolBoolLogicalFunction.cpp) +add_plugin(TneBoolTbool LogicalFunction nes-logical-operators TneBoolTboolLogicalFunction.cpp) +add_plugin(TneTfloatFloat LogicalFunction nes-logical-operators TneTfloatFloatLogicalFunction.cpp) +add_plugin(TneFloatTfloat LogicalFunction nes-logical-operators TneFloatTfloatLogicalFunction.cpp) +add_plugin(TneTintInt LogicalFunction nes-logical-operators TneTintIntLogicalFunction.cpp) +add_plugin(TneIntTint LogicalFunction nes-logical-operators TneIntTintLogicalFunction.cpp) +add_plugin(TneTemporalTemporal LogicalFunction nes-logical-operators TneTemporalTemporalLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TneBoolTboolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TneBoolTboolLogicalFunction.cpp new file mode 100644 index 0000000000..c70f8b5ad8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TneBoolTboolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TneBoolTboolLogicalFunction::TneBoolTboolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TneBoolTboolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TneBoolTboolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TneBoolTboolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TneBoolTboolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TneBoolTboolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TneBoolTboolLogicalFunction::getType() const { return NAME; } + +bool TneBoolTboolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TneBoolTboolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TneBoolTboolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TneBoolTboolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTneBoolTboolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TneBoolTboolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TneBoolTboolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TneFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TneFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..53698fc13f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TneFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TneFloatTfloatLogicalFunction::TneFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TneFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TneFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TneFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TneFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TneFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TneFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool TneFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TneFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TneFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TneFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTneFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TneFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TneFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TneIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TneIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..9ae1544bad --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TneIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TneIntTintLogicalFunction::TneIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TneIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TneIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TneIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TneIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TneIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TneIntTintLogicalFunction::getType() const { return NAME; } + +bool TneIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TneIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TneIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TneIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTneIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TneIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TneIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TneTboolBoolLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TneTboolBoolLogicalFunction.cpp new file mode 100644 index 0000000000..4e6d17868d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TneTboolBoolLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TneTboolBoolLogicalFunction::TneTboolBoolLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TneTboolBoolLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TneTboolBoolLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TneTboolBoolLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TneTboolBoolLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TneTboolBoolLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TneTboolBoolLogicalFunction::getType() const { return NAME; } + +bool TneTboolBoolLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TneTboolBoolLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TneTboolBoolLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TneTboolBoolLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTneTboolBoolLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TneTboolBoolLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TneTboolBoolLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TneTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TneTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..15230d5977 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TneTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TneTemporalTemporalLogicalFunction::TneTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TneTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TneTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TneTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TneTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TneTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TneTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool TneTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TneTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TneTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TneTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTneTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TneTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TneTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TneTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TneTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..6ae75fcf41 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TneTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TneTfloatFloatLogicalFunction::TneTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TneTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TneTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TneTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TneTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TneTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TneTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool TneTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TneTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TneTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TneTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTneTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TneTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TneTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TneTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TneTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..92432fa878 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TneTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TneTintIntLogicalFunction::TneTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TneTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TneTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TneTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TneTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TneTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TneTintIntLogicalFunction::getType() const { return NAME; } + +bool TneTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TneTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TneTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TneTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTneTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TneTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TneTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TneBoolTboolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TneBoolTboolPhysicalFunction.hpp new file mode 100644 index 0000000000..b9d2bfccf8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TneBoolTboolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tne_bool_tbool`. + * + * temporal NE: scalar bool vs single-instant tbool + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TneBoolTboolPhysicalFunction : public PhysicalFunctionConcept { +public: + TneBoolTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TneFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TneFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..8249e9e4c3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TneFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tne_float_tfloat`. + * + * temporal NE: scalar float vs single-instant tfloat + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TneFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TneFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TneIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TneIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..fe6f8abb74 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TneIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tne_int_tint`. + * + * temporal NE: scalar int vs single-instant tint + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TneIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + TneIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TneTboolBoolPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TneTboolBoolPhysicalFunction.hpp new file mode 100644 index 0000000000..543dab6dc5 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TneTboolBoolPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tne_tbool_bool`. + * + * temporal NE: single-instant tbool vs scalar bool + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TneTboolBoolPhysicalFunction : public PhysicalFunctionConcept { +public: + TneTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TneTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TneTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..a505eafb90 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TneTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tne_temporal_temporal`. + * + * temporal NE: two single-instant tfloats + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TneTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + TneTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TneTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TneTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..166bce1a7a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TneTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tne_tfloat_float`. + * + * temporal NE: single-instant tfloat vs scalar float + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TneTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TneTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TneTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TneTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..32c2aae1e4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TneTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tne_tint_int`. + * + * temporal NE: single-instant tint vs scalar int + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TneTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + TneTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 5005e9d8b2..7430f3fc05 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -217,4 +217,11 @@ add_plugin(TeqTboolBool PhysicalFunction nes-physical-operators TeqTboolBoolPhys add_plugin(TeqTemporalTemporal PhysicalFunction nes-physical-operators TeqTemporalTemporalPhysicalFunction.cpp) add_plugin(TeqTfloatFloat PhysicalFunction nes-physical-operators TeqTfloatFloatPhysicalFunction.cpp) add_plugin(TeqTintInt PhysicalFunction nes-physical-operators TeqTintIntPhysicalFunction.cpp) +add_plugin(TneTboolBool PhysicalFunction nes-physical-operators TneTboolBoolPhysicalFunction.cpp) +add_plugin(TneBoolTbool PhysicalFunction nes-physical-operators TneBoolTboolPhysicalFunction.cpp) +add_plugin(TneTfloatFloat PhysicalFunction nes-physical-operators TneTfloatFloatPhysicalFunction.cpp) +add_plugin(TneFloatTfloat PhysicalFunction nes-physical-operators TneFloatTfloatPhysicalFunction.cpp) +add_plugin(TneTintInt PhysicalFunction nes-physical-operators TneTintIntPhysicalFunction.cpp) +add_plugin(TneIntTint PhysicalFunction nes-physical-operators TneIntTintPhysicalFunction.cpp) +add_plugin(TneTemporalTemporal PhysicalFunction nes-physical-operators TneTemporalTemporalPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TneBoolTboolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TneBoolTboolPhysicalFunction.cpp new file mode 100644 index 0000000000..ca66826959 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TneBoolTboolPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TneBoolTboolPhysicalFunction::TneBoolTboolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TneBoolTboolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + bool sv = (v != 0.0); + std::string wkt = fmt::format("{}", (s != 0.0 ? "t" : "f")) + "@" + ts_str; + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tne_bool_tbool(sv, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTneBoolTboolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TneBoolTboolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TneBoolTboolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TneFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TneFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..466d1f8d19 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TneFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TneFloatTfloatPhysicalFunction::TneFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TneFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", s) + "@" + ts_str; + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tne_float_tfloat(v, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTneFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TneFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TneFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TneIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TneIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..1dccbfc071 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TneIntTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TneIntTintPhysicalFunction::TneIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TneIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + int iv = static_cast(v); + std::string wkt = fmt::format("{}", static_cast(s)) + "@" + ts_str; + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tne_int_tint(iv, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTneIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TneIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TneIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TneTboolBoolPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TneTboolBoolPhysicalFunction.cpp new file mode 100644 index 0000000000..f189f48fcf --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TneTboolBoolPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TneTboolBoolPhysicalFunction::TneTboolBoolPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TneTboolBoolPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", (v != 0.0 ? "t" : "f")) + "@" + ts_str; + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + bool sv = (s != 0.0); + Temporal* res = tne_tbool_bool(temp, sv); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTneTboolBoolPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TneTboolBoolPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TneTboolBoolPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TneTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TneTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..362eae034d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TneTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TneTemporalTemporalPhysicalFunction::TneTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TneTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}", v) + "@" + ts_str; + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + std::string wkt2 = fmt::format("{}", s) + "@" + ts_str; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + Temporal* res = tne_temporal_temporal(temp1, temp2); + free(temp1); free(temp2); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTneTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TneTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TneTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TneTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TneTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..b7d1b7a8b9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TneTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TneTfloatFloatPhysicalFunction::TneTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TneTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", v) + "@" + ts_str; + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tne_tfloat_float(temp, s); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTneTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TneTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TneTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TneTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TneTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..5b6daac349 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TneTintIntPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TneTintIntPhysicalFunction::TneTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TneTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", static_cast(v)) + "@" + ts_str; + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int iv = static_cast(s); + Temporal* res = tne_tint_int(temp, iv); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTneTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TneTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TneTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 0fcbd50d39..527e926cb9 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL; sinkClause: INTO sink (',' sink)*; @@ -688,6 +688,13 @@ TEQ_TBOOL_BOOL: 'TEQ_TBOOL_BOOL' | 'teq_tbool_bool'; TEQ_TEMPORAL_TEMPORAL: 'TEQ_TEMPORAL_TEMPORAL' | 'teq_temporal_temporal'; TEQ_TFLOAT_FLOAT: 'TEQ_TFLOAT_FLOAT' | 'teq_tfloat_float'; TEQ_TINT_INT: 'TEQ_TINT_INT' | 'teq_tint_int'; +TNE_TBOOL_BOOL: 'TNE_TBOOL_BOOL' | 'tne_tbool_bool'; +TNE_BOOL_TBOOL: 'TNE_BOOL_TBOOL' | 'tne_bool_tbool'; +TNE_TFLOAT_FLOAT: 'TNE_TFLOAT_FLOAT' | 'tne_tfloat_float'; +TNE_FLOAT_TFLOAT: 'TNE_FLOAT_TFLOAT' | 'tne_float_tfloat'; +TNE_TINT_INT: 'TNE_TINT_INT' | 'tne_tint_int'; +TNE_INT_TINT: 'TNE_INT_TINT' | 'tne_int_tint'; +TNE_TEMPORAL_TEMPORAL: 'TNE_TEMPORAL_TEMPORAL' | 'tne_temporal_temporal'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index ead24af3c4..62771e8da9 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -269,6 +269,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -6825,6 +6832,209 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont }} break; /* END CODEGEN PARSER GLUE: TEQ_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: TNE_TBOOL_BOOL */ + case AntlrSQLLexer::TNE_TBOOL_BOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TNE_TBOOL_BOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TneTboolBoolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TNE_TBOOL_BOOL */ + /* BEGIN CODEGEN PARSER GLUE: TNE_BOOL_TBOOL */ + case AntlrSQLLexer::TNE_BOOL_TBOOL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TNE_BOOL_TBOOL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TneBoolTboolLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TNE_BOOL_TBOOL */ + /* BEGIN CODEGEN PARSER GLUE: TNE_TFLOAT_FLOAT */ + case AntlrSQLLexer::TNE_TFLOAT_FLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TNE_TFLOAT_FLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TneTfloatFloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TNE_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TNE_FLOAT_TFLOAT */ + case AntlrSQLLexer::TNE_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TNE_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TneFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TNE_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TNE_TINT_INT */ + case AntlrSQLLexer::TNE_TINT_INT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TNE_TINT_INT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TneTintIntLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TNE_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: TNE_INT_TINT */ + case AntlrSQLLexer::TNE_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TNE_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TneIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TNE_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: TNE_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::TNE_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TNE_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TneTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TNE_TEMPORAL_TEMPORAL */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 90acfd903586142d50be559cfb93d3f0a784903f Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 10:57:41 +0200 Subject: [PATCH 37/86] feat(meos): add TGE_{FLOAT_TFLOAT,TFLOAT_FLOAT,INT_TINT,TINT_INT,TEMPORAL_TEMPORAL} NES operators (W88) --- .../Meos/TgeFloatTfloatLogicalFunction.hpp | 54 +++++++ .../Meos/TgeIntTintLogicalFunction.hpp | 54 +++++++ .../TgeTemporalTemporalLogicalFunction.hpp | 54 +++++++ .../Meos/TgeTfloatFloatLogicalFunction.hpp | 54 +++++++ .../Meos/TgeTintIntLogicalFunction.hpp | 54 +++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../Meos/TgeFloatTfloatLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TgeIntTintLogicalFunction.cpp | 105 ++++++++++++++ .../TgeTemporalTemporalLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TgeTfloatFloatLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TgeTintIntLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TgeFloatTfloatPhysicalFunction.hpp | 43 ++++++ .../Meos/TgeIntTintPhysicalFunction.hpp | 43 ++++++ .../TgeTemporalTemporalPhysicalFunction.hpp | 43 ++++++ .../Meos/TgeTfloatFloatPhysicalFunction.hpp | 43 ++++++ .../Meos/TgeTintIntPhysicalFunction.hpp | 43 ++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../Meos/TgeFloatTfloatPhysicalFunction.cpp | 92 ++++++++++++ .../Meos/TgeIntTintPhysicalFunction.cpp | 93 ++++++++++++ .../TgeTemporalTemporalPhysicalFunction.cpp | 95 ++++++++++++ .../Meos/TgeTfloatFloatPhysicalFunction.cpp | 92 ++++++++++++ .../Meos/TgeTintIntPhysicalFunction.cpp | 93 ++++++++++++ nes-sql-parser/AntlrSQL.g4 | 7 +- .../src/AntlrSQLQueryPlanCreator.cpp | 135 ++++++++++++++++++ 24 files changed, 1626 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TgeFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TgeIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TgeTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TgeTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TgeTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgeFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgeIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgeTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgeTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgeTintIntLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgeFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgeIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgeTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgeTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgeTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgeFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgeIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgeTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgeTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgeTintIntPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TgeFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgeFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..f5d29f03b1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgeFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal GE: scalar float vs single-instant tfloat + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tge_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TgeFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgeFloatTfloat"; + + TgeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TgeIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgeIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..520ebc852d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgeIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal GE: scalar int vs single-instant tint + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tge_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TgeIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgeIntTint"; + + TgeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TgeTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgeTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..1863d15afb --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgeTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal GE: two single-instant tfloats + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tge_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TgeTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgeTemporalTemporal"; + + TgeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TgeTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgeTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..b503951567 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgeTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal GE: single-instant tfloat vs scalar float + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tge_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TgeTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgeTfloatFloat"; + + TgeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TgeTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgeTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..339a944fd6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgeTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal GE: single-instant tint vs scalar int + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tge_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TgeTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgeTintInt"; + + TgeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 72afd241e5..c1cb0997aa 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -225,3 +225,8 @@ add_plugin(TneFloatTfloat LogicalFunction nes-logical-operators TneFloatTfloatLo add_plugin(TneTintInt LogicalFunction nes-logical-operators TneTintIntLogicalFunction.cpp) add_plugin(TneIntTint LogicalFunction nes-logical-operators TneIntTintLogicalFunction.cpp) add_plugin(TneTemporalTemporal LogicalFunction nes-logical-operators TneTemporalTemporalLogicalFunction.cpp) +add_plugin(TgeTfloatFloat LogicalFunction nes-logical-operators TgeTfloatFloatLogicalFunction.cpp) +add_plugin(TgeFloatTfloat LogicalFunction nes-logical-operators TgeFloatTfloatLogicalFunction.cpp) +add_plugin(TgeTintInt LogicalFunction nes-logical-operators TgeTintIntLogicalFunction.cpp) +add_plugin(TgeIntTint LogicalFunction nes-logical-operators TgeIntTintLogicalFunction.cpp) +add_plugin(TgeTemporalTemporal LogicalFunction nes-logical-operators TgeTemporalTemporalLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TgeFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgeFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..1cfed39a8c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgeFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TgeFloatTfloatLogicalFunction::TgeFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TgeFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgeFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TgeFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgeFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TgeFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TgeFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool TgeFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TgeFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TgeFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TgeFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTgeFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TgeFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TgeFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TgeIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgeIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..77941fda80 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgeIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TgeIntTintLogicalFunction::TgeIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TgeIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgeIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TgeIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgeIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TgeIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TgeIntTintLogicalFunction::getType() const { return NAME; } + +bool TgeIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TgeIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TgeIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TgeIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTgeIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TgeIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TgeIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TgeTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgeTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..ff9c31e5c9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgeTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TgeTemporalTemporalLogicalFunction::TgeTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TgeTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgeTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TgeTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgeTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TgeTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TgeTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool TgeTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TgeTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TgeTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TgeTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTgeTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TgeTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TgeTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TgeTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgeTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..448d75c23d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgeTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TgeTfloatFloatLogicalFunction::TgeTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TgeTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgeTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TgeTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgeTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TgeTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TgeTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool TgeTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TgeTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TgeTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TgeTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTgeTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TgeTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TgeTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TgeTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgeTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..5598f68354 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgeTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TgeTintIntLogicalFunction::TgeTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TgeTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgeTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TgeTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgeTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TgeTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TgeTintIntLogicalFunction::getType() const { return NAME; } + +bool TgeTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TgeTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TgeTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TgeTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTgeTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TgeTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TgeTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgeFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgeFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..e089b1b7b6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgeFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tge_float_tfloat`. + * + * temporal GE: scalar float vs single-instant tfloat + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TgeFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TgeFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgeIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgeIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..6b66843036 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgeIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tge_int_tint`. + * + * temporal GE: scalar int vs single-instant tint + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TgeIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + TgeIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgeTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgeTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..a3b2075f4e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgeTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tge_temporal_temporal`. + * + * temporal GE: two single-instant tfloats + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TgeTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + TgeTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgeTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgeTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..b8c3d84730 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgeTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tge_tfloat_float`. + * + * temporal GE: single-instant tfloat vs scalar float + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TgeTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TgeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgeTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgeTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..9701a6abd7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgeTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tge_tint_int`. + * + * temporal GE: single-instant tint vs scalar int + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TgeTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + TgeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 7430f3fc05..14266c4da4 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -224,4 +224,9 @@ add_plugin(TneFloatTfloat PhysicalFunction nes-physical-operators TneFloatTfloat add_plugin(TneTintInt PhysicalFunction nes-physical-operators TneTintIntPhysicalFunction.cpp) add_plugin(TneIntTint PhysicalFunction nes-physical-operators TneIntTintPhysicalFunction.cpp) add_plugin(TneTemporalTemporal PhysicalFunction nes-physical-operators TneTemporalTemporalPhysicalFunction.cpp) +add_plugin(TgeTfloatFloat PhysicalFunction nes-physical-operators TgeTfloatFloatPhysicalFunction.cpp) +add_plugin(TgeFloatTfloat PhysicalFunction nes-physical-operators TgeFloatTfloatPhysicalFunction.cpp) +add_plugin(TgeTintInt PhysicalFunction nes-physical-operators TgeTintIntPhysicalFunction.cpp) +add_plugin(TgeIntTint PhysicalFunction nes-physical-operators TgeIntTintPhysicalFunction.cpp) +add_plugin(TgeTemporalTemporal PhysicalFunction nes-physical-operators TgeTemporalTemporalPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TgeFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgeFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..e32d3c5a60 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgeFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TgeFloatTfloatPhysicalFunction::TgeFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TgeFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", s) + "@" + ts_str; + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tge_float_tfloat(v, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgeFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgeFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TgeFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TgeIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgeIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..7f0f90b816 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgeIntTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TgeIntTintPhysicalFunction::TgeIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TgeIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + int iv = static_cast(v); + std::string wkt = fmt::format("{}", static_cast(s)) + "@" + ts_str; + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tge_int_tint(iv, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgeIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgeIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TgeIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TgeTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgeTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..42a791a80d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgeTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TgeTemporalTemporalPhysicalFunction::TgeTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TgeTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}", v) + "@" + ts_str; + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + std::string wkt2 = fmt::format("{}", s) + "@" + ts_str; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + Temporal* res = tge_temporal_temporal(temp1, temp2); + free(temp1); free(temp2); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgeTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgeTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TgeTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TgeTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgeTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..88ef7cd166 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgeTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TgeTfloatFloatPhysicalFunction::TgeTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TgeTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", v) + "@" + ts_str; + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tge_tfloat_float(temp, s); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgeTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgeTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TgeTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TgeTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgeTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..ac371f4b9f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgeTintIntPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TgeTintIntPhysicalFunction::TgeTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TgeTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", static_cast(v)) + "@" + ts_str; + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int iv = static_cast(s); + Temporal* res = tge_tint_int(temp, iv); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgeTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgeTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TgeTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 527e926cb9..cc4518b9cf 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL; sinkClause: INTO sink (',' sink)*; @@ -695,6 +695,11 @@ TNE_FLOAT_TFLOAT: 'TNE_FLOAT_TFLOAT' | 'tne_float_tfloat'; TNE_TINT_INT: 'TNE_TINT_INT' | 'tne_tint_int'; TNE_INT_TINT: 'TNE_INT_TINT' | 'tne_int_tint'; TNE_TEMPORAL_TEMPORAL: 'TNE_TEMPORAL_TEMPORAL' | 'tne_temporal_temporal'; +TGE_TFLOAT_FLOAT: 'TGE_TFLOAT_FLOAT' | 'tge_tfloat_float'; +TGE_FLOAT_TFLOAT: 'TGE_FLOAT_TFLOAT' | 'tge_float_tfloat'; +TGE_TINT_INT: 'TGE_TINT_INT' | 'tge_tint_int'; +TGE_INT_TINT: 'TGE_INT_TINT' | 'tge_int_tint'; +TGE_TEMPORAL_TEMPORAL: 'TGE_TEMPORAL_TEMPORAL' | 'tge_temporal_temporal'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 62771e8da9..c45ea20dd3 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -276,6 +276,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -7035,6 +7040,136 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont }} break; /* END CODEGEN PARSER GLUE: TNE_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: TGE_TFLOAT_FLOAT */ + case AntlrSQLLexer::TGE_TFLOAT_FLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGE_TFLOAT_FLOAT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TgeTfloatFloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TGE_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TGE_FLOAT_TFLOAT */ + case AntlrSQLLexer::TGE_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGE_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TgeFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TGE_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TGE_TINT_INT */ + case AntlrSQLLexer::TGE_TINT_INT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGE_TINT_INT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TgeTintIntLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TGE_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: TGE_INT_TINT */ + case AntlrSQLLexer::TGE_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGE_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TgeIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TGE_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: TGE_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::TGE_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGE_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TgeTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TGE_TEMPORAL_TEMPORAL */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From d13dff503b0f7f3bce461b2236a758a2440e5b74 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 10:58:12 +0200 Subject: [PATCH 38/86] feat(meos): add TGT_{FLOAT_TFLOAT,TFLOAT_FLOAT,INT_TINT,TINT_INT,TEMPORAL_TEMPORAL} NES operators (W89) --- .../Meos/TgtFloatTfloatLogicalFunction.hpp | 54 +++++++ .../Meos/TgtIntTintLogicalFunction.hpp | 54 +++++++ .../TgtTemporalTemporalLogicalFunction.hpp | 54 +++++++ .../Meos/TgtTfloatFloatLogicalFunction.hpp | 54 +++++++ .../Meos/TgtTintIntLogicalFunction.hpp | 54 +++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../Meos/TgtFloatTfloatLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TgtIntTintLogicalFunction.cpp | 105 ++++++++++++++ .../TgtTemporalTemporalLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TgtTfloatFloatLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TgtTintIntLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TgtFloatTfloatPhysicalFunction.hpp | 43 ++++++ .../Meos/TgtIntTintPhysicalFunction.hpp | 43 ++++++ .../TgtTemporalTemporalPhysicalFunction.hpp | 43 ++++++ .../Meos/TgtTfloatFloatPhysicalFunction.hpp | 43 ++++++ .../Meos/TgtTintIntPhysicalFunction.hpp | 43 ++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../Meos/TgtFloatTfloatPhysicalFunction.cpp | 92 ++++++++++++ .../Meos/TgtIntTintPhysicalFunction.cpp | 93 ++++++++++++ .../TgtTemporalTemporalPhysicalFunction.cpp | 95 ++++++++++++ .../Meos/TgtTfloatFloatPhysicalFunction.cpp | 92 ++++++++++++ .../Meos/TgtTintIntPhysicalFunction.cpp | 93 ++++++++++++ nes-sql-parser/AntlrSQL.g4 | 7 +- .../src/AntlrSQLQueryPlanCreator.cpp | 135 ++++++++++++++++++ 24 files changed, 1626 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TgtFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TgtIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TgtTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TgtTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TgtTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgtFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgtIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgtTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgtTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgtTintIntLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgtFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgtIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgtTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgtTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgtTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgtFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgtIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgtTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgtTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgtTintIntPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TgtFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgtFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..a09af69ddf --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgtFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal GT: scalar float vs single-instant tfloat + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tgt_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TgtFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgtFloatTfloat"; + + TgtFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TgtIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgtIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..45e8c6bdea --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgtIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal GT: scalar int vs single-instant tint + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tgt_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TgtIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgtIntTint"; + + TgtIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TgtTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgtTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..3fb1475804 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgtTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal GT: two single-instant tfloats + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tgt_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TgtTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgtTemporalTemporal"; + + TgtTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TgtTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgtTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..c3edc575a6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgtTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal GT: single-instant tfloat vs scalar float + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tgt_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TgtTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgtTfloatFloat"; + + TgtTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TgtTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgtTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..150853283a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgtTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal GT: single-instant tint vs scalar int + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tgt_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TgtTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgtTintInt"; + + TgtTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index c1cb0997aa..360798a2c2 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -230,3 +230,8 @@ add_plugin(TgeFloatTfloat LogicalFunction nes-logical-operators TgeFloatTfloatLo add_plugin(TgeTintInt LogicalFunction nes-logical-operators TgeTintIntLogicalFunction.cpp) add_plugin(TgeIntTint LogicalFunction nes-logical-operators TgeIntTintLogicalFunction.cpp) add_plugin(TgeTemporalTemporal LogicalFunction nes-logical-operators TgeTemporalTemporalLogicalFunction.cpp) +add_plugin(TgtTfloatFloat LogicalFunction nes-logical-operators TgtTfloatFloatLogicalFunction.cpp) +add_plugin(TgtFloatTfloat LogicalFunction nes-logical-operators TgtFloatTfloatLogicalFunction.cpp) +add_plugin(TgtTintInt LogicalFunction nes-logical-operators TgtTintIntLogicalFunction.cpp) +add_plugin(TgtIntTint LogicalFunction nes-logical-operators TgtIntTintLogicalFunction.cpp) +add_plugin(TgtTemporalTemporal LogicalFunction nes-logical-operators TgtTemporalTemporalLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TgtFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgtFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..cfa410e6f1 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgtFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TgtFloatTfloatLogicalFunction::TgtFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TgtFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgtFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TgtFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgtFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TgtFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TgtFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool TgtFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TgtFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TgtFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TgtFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTgtFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TgtFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TgtFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TgtIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgtIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..9a7e98afbf --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgtIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TgtIntTintLogicalFunction::TgtIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TgtIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgtIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TgtIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgtIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TgtIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TgtIntTintLogicalFunction::getType() const { return NAME; } + +bool TgtIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TgtIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TgtIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TgtIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTgtIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TgtIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TgtIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TgtTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgtTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..28fb2ab498 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgtTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TgtTemporalTemporalLogicalFunction::TgtTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TgtTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgtTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TgtTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgtTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TgtTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TgtTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool TgtTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TgtTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TgtTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TgtTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTgtTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TgtTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TgtTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TgtTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgtTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..248fc1010f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgtTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TgtTfloatFloatLogicalFunction::TgtTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TgtTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgtTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TgtTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgtTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TgtTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TgtTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool TgtTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TgtTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TgtTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TgtTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTgtTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TgtTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TgtTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TgtTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgtTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..03c55b400a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgtTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TgtTintIntLogicalFunction::TgtTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TgtTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgtTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TgtTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgtTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TgtTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TgtTintIntLogicalFunction::getType() const { return NAME; } + +bool TgtTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TgtTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TgtTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TgtTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTgtTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TgtTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TgtTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgtFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgtFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..101111008c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgtFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tgt_float_tfloat`. + * + * temporal GT: scalar float vs single-instant tfloat + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TgtFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TgtFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgtIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgtIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..792f1bf20c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgtIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tgt_int_tint`. + * + * temporal GT: scalar int vs single-instant tint + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TgtIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + TgtIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgtTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgtTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..6b4cd4889d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgtTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tgt_temporal_temporal`. + * + * temporal GT: two single-instant tfloats + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TgtTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + TgtTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgtTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgtTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..1bc69bbba9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgtTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tgt_tfloat_float`. + * + * temporal GT: single-instant tfloat vs scalar float + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TgtTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TgtTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgtTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgtTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..1f0f388683 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgtTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tgt_tint_int`. + * + * temporal GT: single-instant tint vs scalar int + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TgtTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + TgtTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 14266c4da4..c115a6726e 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -229,4 +229,9 @@ add_plugin(TgeFloatTfloat PhysicalFunction nes-physical-operators TgeFloatTfloat add_plugin(TgeTintInt PhysicalFunction nes-physical-operators TgeTintIntPhysicalFunction.cpp) add_plugin(TgeIntTint PhysicalFunction nes-physical-operators TgeIntTintPhysicalFunction.cpp) add_plugin(TgeTemporalTemporal PhysicalFunction nes-physical-operators TgeTemporalTemporalPhysicalFunction.cpp) +add_plugin(TgtTfloatFloat PhysicalFunction nes-physical-operators TgtTfloatFloatPhysicalFunction.cpp) +add_plugin(TgtFloatTfloat PhysicalFunction nes-physical-operators TgtFloatTfloatPhysicalFunction.cpp) +add_plugin(TgtTintInt PhysicalFunction nes-physical-operators TgtTintIntPhysicalFunction.cpp) +add_plugin(TgtIntTint PhysicalFunction nes-physical-operators TgtIntTintPhysicalFunction.cpp) +add_plugin(TgtTemporalTemporal PhysicalFunction nes-physical-operators TgtTemporalTemporalPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TgtFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgtFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..aa730bdfff --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgtFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TgtFloatTfloatPhysicalFunction::TgtFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TgtFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", s) + "@" + ts_str; + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tgt_float_tfloat(v, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgtFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgtFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TgtFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TgtIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgtIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..b90ecefb11 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgtIntTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TgtIntTintPhysicalFunction::TgtIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TgtIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + int iv = static_cast(v); + std::string wkt = fmt::format("{}", static_cast(s)) + "@" + ts_str; + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tgt_int_tint(iv, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgtIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgtIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TgtIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TgtTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgtTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..8ebbf0a415 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgtTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TgtTemporalTemporalPhysicalFunction::TgtTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TgtTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}", v) + "@" + ts_str; + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + std::string wkt2 = fmt::format("{}", s) + "@" + ts_str; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + Temporal* res = tgt_temporal_temporal(temp1, temp2); + free(temp1); free(temp2); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgtTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgtTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TgtTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TgtTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgtTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..18b7af8a43 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgtTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TgtTfloatFloatPhysicalFunction::TgtTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TgtTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", v) + "@" + ts_str; + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tgt_tfloat_float(temp, s); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgtTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgtTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TgtTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TgtTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgtTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..dd128e2716 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgtTintIntPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TgtTintIntPhysicalFunction::TgtTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TgtTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", static_cast(v)) + "@" + ts_str; + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int iv = static_cast(s); + Temporal* res = tgt_tint_int(temp, iv); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgtTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgtTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TgtTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index cc4518b9cf..15a1bf5d5a 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL; sinkClause: INTO sink (',' sink)*; @@ -700,6 +700,11 @@ TGE_FLOAT_TFLOAT: 'TGE_FLOAT_TFLOAT' | 'tge_float_tfloat'; TGE_TINT_INT: 'TGE_TINT_INT' | 'tge_tint_int'; TGE_INT_TINT: 'TGE_INT_TINT' | 'tge_int_tint'; TGE_TEMPORAL_TEMPORAL: 'TGE_TEMPORAL_TEMPORAL' | 'tge_temporal_temporal'; +TGT_TFLOAT_FLOAT: 'TGT_TFLOAT_FLOAT' | 'tgt_tfloat_float'; +TGT_FLOAT_TFLOAT: 'TGT_FLOAT_TFLOAT' | 'tgt_float_tfloat'; +TGT_TINT_INT: 'TGT_TINT_INT' | 'tgt_tint_int'; +TGT_INT_TINT: 'TGT_INT_TINT' | 'tgt_int_tint'; +TGT_TEMPORAL_TEMPORAL: 'TGT_TEMPORAL_TEMPORAL' | 'tgt_temporal_temporal'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index c45ea20dd3..e2097d915c 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -281,6 +281,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -7170,6 +7175,136 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont }} break; /* END CODEGEN PARSER GLUE: TGE_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: TGT_TFLOAT_FLOAT */ + case AntlrSQLLexer::TGT_TFLOAT_FLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGT_TFLOAT_FLOAT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TgtTfloatFloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TGT_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TGT_FLOAT_TFLOAT */ + case AntlrSQLLexer::TGT_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGT_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TgtFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TGT_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TGT_TINT_INT */ + case AntlrSQLLexer::TGT_TINT_INT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGT_TINT_INT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TgtTintIntLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TGT_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: TGT_INT_TINT */ + case AntlrSQLLexer::TGT_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGT_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TgtIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TGT_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: TGT_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::TGT_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGT_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TgtTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TGT_TEMPORAL_TEMPORAL */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 80d12c3b79effd2deb4526e46876b84f9ff765a1 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 10:58:40 +0200 Subject: [PATCH 39/86] feat(meos): add TLE_{FLOAT_TFLOAT,TFLOAT_FLOAT,INT_TINT,TINT_INT,TEMPORAL_TEMPORAL} NES operators (W90) --- .../Meos/TleFloatTfloatLogicalFunction.hpp | 54 +++++++ .../Meos/TleIntTintLogicalFunction.hpp | 54 +++++++ .../TleTemporalTemporalLogicalFunction.hpp | 54 +++++++ .../Meos/TleTfloatFloatLogicalFunction.hpp | 54 +++++++ .../Meos/TleTintIntLogicalFunction.hpp | 54 +++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../Meos/TleFloatTfloatLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TleIntTintLogicalFunction.cpp | 105 ++++++++++++++ .../TleTemporalTemporalLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TleTfloatFloatLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TleTintIntLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TleFloatTfloatPhysicalFunction.hpp | 43 ++++++ .../Meos/TleIntTintPhysicalFunction.hpp | 43 ++++++ .../TleTemporalTemporalPhysicalFunction.hpp | 43 ++++++ .../Meos/TleTfloatFloatPhysicalFunction.hpp | 43 ++++++ .../Meos/TleTintIntPhysicalFunction.hpp | 43 ++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../Meos/TleFloatTfloatPhysicalFunction.cpp | 92 ++++++++++++ .../Meos/TleIntTintPhysicalFunction.cpp | 93 ++++++++++++ .../TleTemporalTemporalPhysicalFunction.cpp | 95 ++++++++++++ .../Meos/TleTfloatFloatPhysicalFunction.cpp | 92 ++++++++++++ .../Meos/TleTintIntPhysicalFunction.cpp | 93 ++++++++++++ nes-sql-parser/AntlrSQL.g4 | 7 +- .../src/AntlrSQLQueryPlanCreator.cpp | 135 ++++++++++++++++++ 24 files changed, 1626 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TleFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TleIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TleTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TleTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TleTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TleFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TleIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TleTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TleTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TleTintIntLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TleFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TleIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TleTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TleTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TleTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TleFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TleIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TleTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TleTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TleTintIntPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TleFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TleFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..b1fd622e7b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TleFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal LE: scalar float vs single-instant tfloat + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tle_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TleFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TleFloatTfloat"; + + TleFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TleIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TleIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..8d1d9f8d1e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TleIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal LE: scalar int vs single-instant tint + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tle_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TleIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TleIntTint"; + + TleIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TleTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TleTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..cf826911e5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TleTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal LE: two single-instant tfloats + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tle_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TleTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TleTemporalTemporal"; + + TleTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TleTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TleTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..7b61305728 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TleTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal LE: single-instant tfloat vs scalar float + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tle_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TleTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TleTfloatFloat"; + + TleTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TleTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TleTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..ef0f527ed5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TleTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal LE: single-instant tint vs scalar int + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tle_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TleTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TleTintInt"; + + TleTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 360798a2c2..8904abe40a 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -235,3 +235,8 @@ add_plugin(TgtFloatTfloat LogicalFunction nes-logical-operators TgtFloatTfloatLo add_plugin(TgtTintInt LogicalFunction nes-logical-operators TgtTintIntLogicalFunction.cpp) add_plugin(TgtIntTint LogicalFunction nes-logical-operators TgtIntTintLogicalFunction.cpp) add_plugin(TgtTemporalTemporal LogicalFunction nes-logical-operators TgtTemporalTemporalLogicalFunction.cpp) +add_plugin(TleTfloatFloat LogicalFunction nes-logical-operators TleTfloatFloatLogicalFunction.cpp) +add_plugin(TleFloatTfloat LogicalFunction nes-logical-operators TleFloatTfloatLogicalFunction.cpp) +add_plugin(TleTintInt LogicalFunction nes-logical-operators TleTintIntLogicalFunction.cpp) +add_plugin(TleIntTint LogicalFunction nes-logical-operators TleIntTintLogicalFunction.cpp) +add_plugin(TleTemporalTemporal LogicalFunction nes-logical-operators TleTemporalTemporalLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TleFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TleFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..d38e8db5b8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TleFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TleFloatTfloatLogicalFunction::TleFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TleFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TleFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TleFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TleFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TleFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TleFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool TleFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TleFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TleFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TleFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTleFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TleFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TleFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TleIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TleIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..aec8aff17e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TleIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TleIntTintLogicalFunction::TleIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TleIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TleIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TleIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TleIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TleIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TleIntTintLogicalFunction::getType() const { return NAME; } + +bool TleIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TleIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TleIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TleIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTleIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TleIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TleIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TleTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TleTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..bf9d4b4aa9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TleTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TleTemporalTemporalLogicalFunction::TleTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TleTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TleTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TleTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TleTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TleTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TleTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool TleTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TleTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TleTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TleTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTleTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TleTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TleTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TleTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TleTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..58c9720fe3 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TleTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TleTfloatFloatLogicalFunction::TleTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TleTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TleTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TleTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TleTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TleTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TleTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool TleTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TleTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TleTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TleTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTleTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TleTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TleTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TleTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TleTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..7b307b6334 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TleTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TleTintIntLogicalFunction::TleTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TleTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TleTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TleTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TleTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TleTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TleTintIntLogicalFunction::getType() const { return NAME; } + +bool TleTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TleTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TleTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TleTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTleTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TleTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TleTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TleFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TleFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..b94ed0840d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TleFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tle_float_tfloat`. + * + * temporal LE: scalar float vs single-instant tfloat + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TleFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TleFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TleIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TleIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..70e367064f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TleIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tle_int_tint`. + * + * temporal LE: scalar int vs single-instant tint + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TleIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + TleIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TleTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TleTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..f454e0a539 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TleTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tle_temporal_temporal`. + * + * temporal LE: two single-instant tfloats + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TleTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + TleTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TleTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TleTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..eeb9616357 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TleTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tle_tfloat_float`. + * + * temporal LE: single-instant tfloat vs scalar float + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TleTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TleTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TleTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TleTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..a80e8a9434 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TleTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tle_tint_int`. + * + * temporal LE: single-instant tint vs scalar int + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TleTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + TleTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index c115a6726e..1b75d342df 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -234,4 +234,9 @@ add_plugin(TgtFloatTfloat PhysicalFunction nes-physical-operators TgtFloatTfloat add_plugin(TgtTintInt PhysicalFunction nes-physical-operators TgtTintIntPhysicalFunction.cpp) add_plugin(TgtIntTint PhysicalFunction nes-physical-operators TgtIntTintPhysicalFunction.cpp) add_plugin(TgtTemporalTemporal PhysicalFunction nes-physical-operators TgtTemporalTemporalPhysicalFunction.cpp) +add_plugin(TleTfloatFloat PhysicalFunction nes-physical-operators TleTfloatFloatPhysicalFunction.cpp) +add_plugin(TleFloatTfloat PhysicalFunction nes-physical-operators TleFloatTfloatPhysicalFunction.cpp) +add_plugin(TleTintInt PhysicalFunction nes-physical-operators TleTintIntPhysicalFunction.cpp) +add_plugin(TleIntTint PhysicalFunction nes-physical-operators TleIntTintPhysicalFunction.cpp) +add_plugin(TleTemporalTemporal PhysicalFunction nes-physical-operators TleTemporalTemporalPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TleFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TleFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..9e588a943f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TleFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TleFloatTfloatPhysicalFunction::TleFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TleFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", s) + "@" + ts_str; + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tle_float_tfloat(v, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTleFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TleFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TleFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TleIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TleIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..718a24c5bf --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TleIntTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TleIntTintPhysicalFunction::TleIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TleIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + int iv = static_cast(v); + std::string wkt = fmt::format("{}", static_cast(s)) + "@" + ts_str; + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tle_int_tint(iv, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTleIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TleIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TleIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TleTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TleTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..52ef2a907c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TleTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TleTemporalTemporalPhysicalFunction::TleTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TleTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}", v) + "@" + ts_str; + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + std::string wkt2 = fmt::format("{}", s) + "@" + ts_str; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + Temporal* res = tle_temporal_temporal(temp1, temp2); + free(temp1); free(temp2); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTleTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TleTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TleTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TleTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TleTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..f32e625511 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TleTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TleTfloatFloatPhysicalFunction::TleTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TleTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", v) + "@" + ts_str; + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tle_tfloat_float(temp, s); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTleTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TleTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TleTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TleTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TleTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..c4b082f408 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TleTintIntPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TleTintIntPhysicalFunction::TleTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TleTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", static_cast(v)) + "@" + ts_str; + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int iv = static_cast(s); + Temporal* res = tle_tint_int(temp, iv); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTleTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TleTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TleTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 15a1bf5d5a..44a61b712f 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL; sinkClause: INTO sink (',' sink)*; @@ -705,6 +705,11 @@ TGT_FLOAT_TFLOAT: 'TGT_FLOAT_TFLOAT' | 'tgt_float_tfloat'; TGT_TINT_INT: 'TGT_TINT_INT' | 'tgt_tint_int'; TGT_INT_TINT: 'TGT_INT_TINT' | 'tgt_int_tint'; TGT_TEMPORAL_TEMPORAL: 'TGT_TEMPORAL_TEMPORAL' | 'tgt_temporal_temporal'; +TLE_TFLOAT_FLOAT: 'TLE_TFLOAT_FLOAT' | 'tle_tfloat_float'; +TLE_FLOAT_TFLOAT: 'TLE_FLOAT_TFLOAT' | 'tle_float_tfloat'; +TLE_TINT_INT: 'TLE_TINT_INT' | 'tle_tint_int'; +TLE_INT_TINT: 'TLE_INT_TINT' | 'tle_int_tint'; +TLE_TEMPORAL_TEMPORAL: 'TLE_TEMPORAL_TEMPORAL' | 'tle_temporal_temporal'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index e2097d915c..deeabc6731 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -286,6 +286,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -7305,6 +7310,136 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont }} break; /* END CODEGEN PARSER GLUE: TGT_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: TLE_TFLOAT_FLOAT */ + case AntlrSQLLexer::TLE_TFLOAT_FLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLE_TFLOAT_FLOAT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TleTfloatFloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TLE_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TLE_FLOAT_TFLOAT */ + case AntlrSQLLexer::TLE_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLE_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TleFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TLE_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TLE_TINT_INT */ + case AntlrSQLLexer::TLE_TINT_INT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLE_TINT_INT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TleTintIntLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TLE_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: TLE_INT_TINT */ + case AntlrSQLLexer::TLE_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLE_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TleIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TLE_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: TLE_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::TLE_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLE_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TleTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TLE_TEMPORAL_TEMPORAL */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 1d94c6d5d95c39af63a9709a1d36a767fe25400a Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 10:59:08 +0200 Subject: [PATCH 40/86] feat(meos): add TLT_{FLOAT_TFLOAT,TFLOAT_FLOAT,INT_TINT,TINT_INT,TEMPORAL_TEMPORAL} NES operators (W91) --- .../Meos/TltFloatTfloatLogicalFunction.hpp | 54 +++++++ .../Meos/TltIntTintLogicalFunction.hpp | 54 +++++++ .../TltTemporalTemporalLogicalFunction.hpp | 54 +++++++ .../Meos/TltTfloatFloatLogicalFunction.hpp | 54 +++++++ .../Meos/TltTintIntLogicalFunction.hpp | 54 +++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../Meos/TltFloatTfloatLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TltIntTintLogicalFunction.cpp | 105 ++++++++++++++ .../TltTemporalTemporalLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TltTfloatFloatLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TltTintIntLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/TltFloatTfloatPhysicalFunction.hpp | 43 ++++++ .../Meos/TltIntTintPhysicalFunction.hpp | 43 ++++++ .../TltTemporalTemporalPhysicalFunction.hpp | 43 ++++++ .../Meos/TltTfloatFloatPhysicalFunction.hpp | 43 ++++++ .../Meos/TltTintIntPhysicalFunction.hpp | 43 ++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../Meos/TltFloatTfloatPhysicalFunction.cpp | 92 ++++++++++++ .../Meos/TltIntTintPhysicalFunction.cpp | 93 ++++++++++++ .../TltTemporalTemporalPhysicalFunction.cpp | 95 ++++++++++++ .../Meos/TltTfloatFloatPhysicalFunction.cpp | 92 ++++++++++++ .../Meos/TltTintIntPhysicalFunction.cpp | 93 ++++++++++++ nes-sql-parser/AntlrSQL.g4 | 7 +- .../src/AntlrSQLQueryPlanCreator.cpp | 135 ++++++++++++++++++ 24 files changed, 1626 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TltFloatTfloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TltIntTintLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TltTemporalTemporalLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TltTfloatFloatLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TltTintIntLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TltFloatTfloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TltIntTintLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TltTemporalTemporalLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TltTfloatFloatLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TltTintIntLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TltFloatTfloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TltIntTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TltTemporalTemporalPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TltTfloatFloatPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TltTintIntPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TltFloatTfloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TltIntTintPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TltTemporalTemporalPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TltTfloatFloatPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TltTintIntPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TltFloatTfloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TltFloatTfloatLogicalFunction.hpp new file mode 100644 index 0000000000..aa7d6f08d9 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TltFloatTfloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal LT: scalar float vs single-instant tfloat + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tlt_float_tfloat`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TltFloatTfloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TltFloatTfloat"; + + TltFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TltIntTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TltIntTintLogicalFunction.hpp new file mode 100644 index 0000000000..901764a8d9 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TltIntTintLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal LT: scalar int vs single-instant tint + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tlt_int_tint`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TltIntTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TltIntTint"; + + TltIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TltTemporalTemporalLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TltTemporalTemporalLogicalFunction.hpp new file mode 100644 index 0000000000..808172372c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TltTemporalTemporalLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal LT: two single-instant tfloats + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tlt_temporal_temporal`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TltTemporalTemporalLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TltTemporalTemporal"; + + TltTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TltTfloatFloatLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TltTfloatFloatLogicalFunction.hpp new file mode 100644 index 0000000000..ccfd508cb8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TltTfloatFloatLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal LT: single-instant tfloat vs scalar float + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tlt_tfloat_float`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TltTfloatFloatLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TltTfloatFloat"; + + TltTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TltTintIntLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TltTintIntLogicalFunction.hpp new file mode 100644 index 0000000000..5964d62430 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TltTintIntLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief temporal LT: single-instant tint vs scalar int + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tlt_tint_int`. Takes (value:FLOAT64, threshold:FLOAT64, ts:UINT64), + * constructs a single-instant temporal, applies the comparison, and returns FLOAT64 (0.0/1.0). + */ +class TltTintIntLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TltTintInt"; + + TltTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 8904abe40a..376f53b53c 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -240,3 +240,8 @@ add_plugin(TleFloatTfloat LogicalFunction nes-logical-operators TleFloatTfloatLo add_plugin(TleTintInt LogicalFunction nes-logical-operators TleTintIntLogicalFunction.cpp) add_plugin(TleIntTint LogicalFunction nes-logical-operators TleIntTintLogicalFunction.cpp) add_plugin(TleTemporalTemporal LogicalFunction nes-logical-operators TleTemporalTemporalLogicalFunction.cpp) +add_plugin(TltTfloatFloat LogicalFunction nes-logical-operators TltTfloatFloatLogicalFunction.cpp) +add_plugin(TltFloatTfloat LogicalFunction nes-logical-operators TltFloatTfloatLogicalFunction.cpp) +add_plugin(TltTintInt LogicalFunction nes-logical-operators TltTintIntLogicalFunction.cpp) +add_plugin(TltIntTint LogicalFunction nes-logical-operators TltIntTintLogicalFunction.cpp) +add_plugin(TltTemporalTemporal LogicalFunction nes-logical-operators TltTemporalTemporalLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TltFloatTfloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TltFloatTfloatLogicalFunction.cpp new file mode 100644 index 0000000000..07b0f703d0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TltFloatTfloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TltFloatTfloatLogicalFunction::TltFloatTfloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TltFloatTfloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TltFloatTfloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TltFloatTfloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TltFloatTfloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TltFloatTfloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TltFloatTfloatLogicalFunction::getType() const { return NAME; } + +bool TltFloatTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TltFloatTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TltFloatTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TltFloatTfloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTltFloatTfloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TltFloatTfloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TltFloatTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TltIntTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TltIntTintLogicalFunction.cpp new file mode 100644 index 0000000000..170ffeb174 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TltIntTintLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TltIntTintLogicalFunction::TltIntTintLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TltIntTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TltIntTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TltIntTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TltIntTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TltIntTintLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TltIntTintLogicalFunction::getType() const { return NAME; } + +bool TltIntTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TltIntTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TltIntTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TltIntTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTltIntTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TltIntTintLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TltIntTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TltTemporalTemporalLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TltTemporalTemporalLogicalFunction.cpp new file mode 100644 index 0000000000..16f0a1cc86 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TltTemporalTemporalLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TltTemporalTemporalLogicalFunction::TltTemporalTemporalLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TltTemporalTemporalLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TltTemporalTemporalLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TltTemporalTemporalLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TltTemporalTemporalLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TltTemporalTemporalLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TltTemporalTemporalLogicalFunction::getType() const { return NAME; } + +bool TltTemporalTemporalLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TltTemporalTemporalLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TltTemporalTemporalLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TltTemporalTemporalLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTltTemporalTemporalLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TltTemporalTemporalLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TltTemporalTemporalLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TltTfloatFloatLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TltTfloatFloatLogicalFunction.cpp new file mode 100644 index 0000000000..6a5ef0ee75 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TltTfloatFloatLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TltTfloatFloatLogicalFunction::TltTfloatFloatLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TltTfloatFloatLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TltTfloatFloatLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TltTfloatFloatLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TltTfloatFloatLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TltTfloatFloatLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TltTfloatFloatLogicalFunction::getType() const { return NAME; } + +bool TltTfloatFloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TltTfloatFloatLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TltTfloatFloatLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TltTfloatFloatLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTltTfloatFloatLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TltTfloatFloatLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TltTfloatFloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TltTintIntLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TltTintIntLogicalFunction.cpp new file mode 100644 index 0000000000..0d3dc85fa1 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TltTintIntLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TltTintIntLogicalFunction::TltTintIntLogicalFunction(LogicalFunction value, + LogicalFunction threshold, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(threshold)); + parameters.push_back(std::move(ts)); +} + +DataType TltTintIntLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TltTintIntLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TltTintIntLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TltTintIntLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TltTintIntLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TltTintIntLogicalFunction::getType() const { return NAME; } + +bool TltTintIntLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TltTintIntLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TltTintIntLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TltTintIntLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTltTintIntLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TltTintIntLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TltTintIntLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TltFloatTfloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TltFloatTfloatPhysicalFunction.hpp new file mode 100644 index 0000000000..6f0ff75d04 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TltFloatTfloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tlt_float_tfloat`. + * + * temporal LT: scalar float vs single-instant tfloat + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TltFloatTfloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TltFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TltIntTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TltIntTintPhysicalFunction.hpp new file mode 100644 index 0000000000..8d56171971 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TltIntTintPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tlt_int_tint`. + * + * temporal LT: scalar int vs single-instant tint + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TltIntTintPhysicalFunction : public PhysicalFunctionConcept { +public: + TltIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TltTemporalTemporalPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TltTemporalTemporalPhysicalFunction.hpp new file mode 100644 index 0000000000..e654fbf064 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TltTemporalTemporalPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tlt_temporal_temporal`. + * + * temporal LT: two single-instant tfloats + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TltTemporalTemporalPhysicalFunction : public PhysicalFunctionConcept { +public: + TltTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TltTfloatFloatPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TltTfloatFloatPhysicalFunction.hpp new file mode 100644 index 0000000000..1e2de95d6c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TltTfloatFloatPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tlt_tfloat_float`. + * + * temporal LT: single-instant tfloat vs scalar float + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TltTfloatFloatPhysicalFunction : public PhysicalFunctionConcept { +public: + TltTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TltTintIntPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TltTintIntPhysicalFunction.hpp new file mode 100644 index 0000000000..99c07ce804 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TltTintIntPhysicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tlt_tint_int`. + * + * temporal LT: single-instant tint vs scalar int + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TltTintIntPhysicalFunction : public PhysicalFunctionConcept { +public: + TltTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 1b75d342df..1329e88057 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -239,4 +239,9 @@ add_plugin(TleFloatTfloat PhysicalFunction nes-physical-operators TleFloatTfloat add_plugin(TleTintInt PhysicalFunction nes-physical-operators TleTintIntPhysicalFunction.cpp) add_plugin(TleIntTint PhysicalFunction nes-physical-operators TleIntTintPhysicalFunction.cpp) add_plugin(TleTemporalTemporal PhysicalFunction nes-physical-operators TleTemporalTemporalPhysicalFunction.cpp) +add_plugin(TltTfloatFloat PhysicalFunction nes-physical-operators TltTfloatFloatPhysicalFunction.cpp) +add_plugin(TltFloatTfloat PhysicalFunction nes-physical-operators TltFloatTfloatPhysicalFunction.cpp) +add_plugin(TltTintInt PhysicalFunction nes-physical-operators TltTintIntPhysicalFunction.cpp) +add_plugin(TltIntTint PhysicalFunction nes-physical-operators TltIntTintPhysicalFunction.cpp) +add_plugin(TltTemporalTemporal PhysicalFunction nes-physical-operators TltTemporalTemporalPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TltFloatTfloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TltFloatTfloatPhysicalFunction.cpp new file mode 100644 index 0000000000..4dee7b9ee3 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TltFloatTfloatPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TltFloatTfloatPhysicalFunction::TltFloatTfloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TltFloatTfloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", s) + "@" + ts_str; + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tlt_float_tfloat(v, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTltFloatTfloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TltFloatTfloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TltFloatTfloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TltIntTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TltIntTintPhysicalFunction.cpp new file mode 100644 index 0000000000..6bed7490fa --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TltIntTintPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TltIntTintPhysicalFunction::TltIntTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TltIntTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + int iv = static_cast(v); + std::string wkt = fmt::format("{}", static_cast(s)) + "@" + ts_str; + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tlt_int_tint(iv, temp); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTltIntTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TltIntTintPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TltIntTintPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TltTemporalTemporalPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TltTemporalTemporalPhysicalFunction.cpp new file mode 100644 index 0000000000..3ee2eeb6e8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TltTemporalTemporalPhysicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TltTemporalTemporalPhysicalFunction::TltTemporalTemporalPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TltTemporalTemporalPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt1 = fmt::format("{}", v) + "@" + ts_str; + Temporal* temp1 = tfloat_in(wkt1.c_str()); + if (!temp1) return 0.0; + std::string wkt2 = fmt::format("{}", s) + "@" + ts_str; + Temporal* temp2 = tfloat_in(wkt2.c_str()); + if (!temp2) { free(temp1); return 0.0; } + Temporal* res = tlt_temporal_temporal(temp1, temp2); + free(temp1); free(temp2); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTltTemporalTemporalPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TltTemporalTemporalPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TltTemporalTemporalPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TltTfloatFloatPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TltTfloatFloatPhysicalFunction.cpp new file mode 100644 index 0000000000..83bd3eb71d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TltTfloatFloatPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TltTfloatFloatPhysicalFunction::TltTfloatFloatPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TltTfloatFloatPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", v) + "@" + ts_str; + Temporal* temp = tfloat_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tlt_tfloat_float(temp, s); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTltTfloatFloatPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TltTfloatFloatPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TltTfloatFloatPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TltTintIntPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TltTintIntPhysicalFunction.cpp new file mode 100644 index 0000000000..f74e5f9da8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TltTintIntPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TltTintIntPhysicalFunction::TltTintIntPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction thresholdFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(3); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(thresholdFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TltTintIntPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto thresh = parameterValues[1].cast>(); + auto ts = parameterValues[2].cast>(); + + const auto result = nautilus::invoke( + +[](double v, double s, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}", static_cast(v)) + "@" + ts_str; + Temporal* temp = tint_in(wkt.c_str()); + if (!temp) return 0.0; + int iv = static_cast(s); + Temporal* res = tlt_tint_int(temp, iv); + free(temp); + if (!res) return 0.0; + bool r = tbool_start_value(res); + free(res); + return static_cast(r ? 1.0 : 0.0); + } catch (const std::exception&) { return 0.0; } + }, + value, thresh, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTltTintIntPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TltTintIntPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + auto arg2 = std::move(arguments.childFunctions[2]); + return TltTintIntPhysicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 44a61b712f..cb28c14e3f 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL; sinkClause: INTO sink (',' sink)*; @@ -710,6 +710,11 @@ TLE_FLOAT_TFLOAT: 'TLE_FLOAT_TFLOAT' | 'tle_float_tfloat'; TLE_TINT_INT: 'TLE_TINT_INT' | 'tle_tint_int'; TLE_INT_TINT: 'TLE_INT_TINT' | 'tle_int_tint'; TLE_TEMPORAL_TEMPORAL: 'TLE_TEMPORAL_TEMPORAL' | 'tle_temporal_temporal'; +TLT_TFLOAT_FLOAT: 'TLT_TFLOAT_FLOAT' | 'tlt_tfloat_float'; +TLT_FLOAT_TFLOAT: 'TLT_FLOAT_TFLOAT' | 'tlt_float_tfloat'; +TLT_TINT_INT: 'TLT_TINT_INT' | 'tlt_tint_int'; +TLT_INT_TINT: 'TLT_INT_TINT' | 'tlt_int_tint'; +TLT_TEMPORAL_TEMPORAL: 'TLT_TEMPORAL_TEMPORAL' | 'tlt_temporal_temporal'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index deeabc6731..f9544a8eae 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -291,6 +291,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -7440,6 +7445,136 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont }} break; /* END CODEGEN PARSER GLUE: TLE_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: TLT_TFLOAT_FLOAT */ + case AntlrSQLLexer::TLT_TFLOAT_FLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLT_TFLOAT_FLOAT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TltTfloatFloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TLT_TFLOAT_FLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TLT_FLOAT_TFLOAT */ + case AntlrSQLLexer::TLT_FLOAT_TFLOAT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLT_FLOAT_TFLOAT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TltFloatTfloatLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TLT_FLOAT_TFLOAT */ + /* BEGIN CODEGEN PARSER GLUE: TLT_TINT_INT */ + case AntlrSQLLexer::TLT_TINT_INT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLT_TINT_INT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TltTintIntLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TLT_TINT_INT */ + /* BEGIN CODEGEN PARSER GLUE: TLT_INT_TINT */ + case AntlrSQLLexer::TLT_INT_TINT: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLT_INT_TINT requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TltIntTintLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TLT_INT_TINT */ + /* BEGIN CODEGEN PARSER GLUE: TLT_TEMPORAL_TEMPORAL */ + case AntlrSQLLexer::TLT_TEMPORAL_TEMPORAL: + {{ + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLT_TEMPORAL_TEMPORAL requires exactly 3 arguments, but got {{}}", argCount); + while (!helpers.top().constantBuilder.empty()) + {{ + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + }} + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TltTemporalTemporalLogicalFunction(a0, a1, a2)); + }} + break; + /* END CODEGEN PARSER GLUE: TLT_TEMPORAL_TEMPORAL */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 2ad657ec1de3f9ab8b95bbd08645563b750e022f Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Fri, 12 Jun 2026 11:06:32 +0200 Subject: [PATCH 41/86] feat(meos): add TBOOL_TO_TINT NES operator (W92) Adds a per-event NES scalar operator TBOOL_TO_TINT backed by the MEOS tbool_to_tint kernel. The 2-arg operator takes (value:FLOAT64, ts:UINT64), builds a single-instant tbool via tbool_in, delegates to tbool_to_tint, and extracts the tint result via tint_start_value returning FLOAT64. Wired across logical/physical CMakeLists, AntlrSQL.g4 functionName rule and lexer section, and AntlrSQLQueryPlanCreator.cpp. --- .../AlwaysEqTbigintTbigintLogicalFunction.hpp | 6 +- .../Meos/AlwaysEqTintTintLogicalFunction.hpp | 6 +- .../AlwaysGeTbigintTbigintLogicalFunction.hpp | 6 +- .../Meos/AlwaysGeTintTintLogicalFunction.hpp | 6 +- .../AlwaysGtTbigintTbigintLogicalFunction.hpp | 6 +- .../Meos/AlwaysGtTintTintLogicalFunction.hpp | 6 +- .../AlwaysLeTbigintTbigintLogicalFunction.hpp | 6 +- .../Meos/AlwaysLeTintTintLogicalFunction.hpp | 6 +- .../AlwaysLtTbigintTbigintLogicalFunction.hpp | 6 +- .../Meos/AlwaysLtTintTintLogicalFunction.hpp | 6 +- .../AlwaysNeTbigintTbigintLogicalFunction.hpp | 6 +- .../Meos/AlwaysNeTintTintLogicalFunction.hpp | 6 +- .../EverEqTbigintTbigintLogicalFunction.hpp | 6 +- .../Meos/EverEqTintTintLogicalFunction.hpp | 6 +- .../EverGeTbigintTbigintLogicalFunction.hpp | 6 +- .../Meos/EverGeTintTintLogicalFunction.hpp | 6 +- .../EverGtTbigintTbigintLogicalFunction.hpp | 6 +- .../Meos/EverGtTintTintLogicalFunction.hpp | 6 +- .../EverLeTbigintTbigintLogicalFunction.hpp | 6 +- .../Meos/EverLeTintTintLogicalFunction.hpp | 6 +- .../EverLtTbigintTbigintLogicalFunction.hpp | 6 +- .../Meos/EverLtTintTintLogicalFunction.hpp | 6 +- .../EverNeTbigintTbigintLogicalFunction.hpp | 6 +- .../Meos/EverNeTintTintLogicalFunction.hpp | 6 +- .../Meos/TboolToTintLogicalFunction.hpp | 53 +++++++++ .../AlwaysEqTbigintTbigintLogicalFunction.cpp | 32 +++--- .../Meos/AlwaysEqTintTintLogicalFunction.cpp | 32 +++--- .../AlwaysGeTbigintTbigintLogicalFunction.cpp | 32 +++--- .../Meos/AlwaysGeTintTintLogicalFunction.cpp | 32 +++--- .../AlwaysGtTbigintTbigintLogicalFunction.cpp | 32 +++--- .../Meos/AlwaysGtTintTintLogicalFunction.cpp | 32 +++--- .../AlwaysLeTbigintTbigintLogicalFunction.cpp | 32 +++--- .../Meos/AlwaysLeTintTintLogicalFunction.cpp | 32 +++--- .../AlwaysLtTbigintTbigintLogicalFunction.cpp | 32 +++--- .../Meos/AlwaysLtTintTintLogicalFunction.cpp | 32 +++--- .../AlwaysNeTbigintTbigintLogicalFunction.cpp | 32 +++--- .../Meos/AlwaysNeTintTintLogicalFunction.cpp | 32 +++--- .../src/Functions/Meos/CMakeLists.txt | 1 + .../EverEqTbigintTbigintLogicalFunction.cpp | 32 +++--- .../Meos/EverEqTintTintLogicalFunction.cpp | 32 +++--- .../EverGeTbigintTbigintLogicalFunction.cpp | 32 +++--- .../Meos/EverGeTintTintLogicalFunction.cpp | 32 +++--- .../EverGtTbigintTbigintLogicalFunction.cpp | 32 +++--- .../Meos/EverGtTintTintLogicalFunction.cpp | 32 +++--- .../EverLeTbigintTbigintLogicalFunction.cpp | 32 +++--- .../Meos/EverLeTintTintLogicalFunction.cpp | 32 +++--- .../EverLtTbigintTbigintLogicalFunction.cpp | 32 +++--- .../Meos/EverLtTintTintLogicalFunction.cpp | 32 +++--- .../EverNeTbigintTbigintLogicalFunction.cpp | 32 +++--- .../Meos/EverNeTintTintLogicalFunction.cpp | 32 +++--- .../Meos/TboolToTintLogicalFunction.cpp | 102 ++++++++++++++++++ ...AlwaysEqTbigintTbigintPhysicalFunction.hpp | 4 +- .../Meos/AlwaysEqTintTintPhysicalFunction.hpp | 4 +- ...AlwaysGeTbigintTbigintPhysicalFunction.hpp | 4 +- .../Meos/AlwaysGeTintTintPhysicalFunction.hpp | 4 +- ...AlwaysGtTbigintTbigintPhysicalFunction.hpp | 4 +- .../Meos/AlwaysGtTintTintPhysicalFunction.hpp | 4 +- ...AlwaysLeTbigintTbigintPhysicalFunction.hpp | 4 +- .../Meos/AlwaysLeTintTintPhysicalFunction.hpp | 4 +- ...AlwaysLtTbigintTbigintPhysicalFunction.hpp | 4 +- .../Meos/AlwaysLtTintTintPhysicalFunction.hpp | 4 +- ...AlwaysNeTbigintTbigintPhysicalFunction.hpp | 4 +- .../Meos/AlwaysNeTintTintPhysicalFunction.hpp | 4 +- .../EverEqTbigintTbigintPhysicalFunction.hpp | 4 +- .../Meos/EverEqTintTintPhysicalFunction.hpp | 4 +- .../EverGeTbigintTbigintPhysicalFunction.hpp | 4 +- .../Meos/EverGeTintTintPhysicalFunction.hpp | 4 +- .../EverGtTbigintTbigintPhysicalFunction.hpp | 4 +- .../Meos/EverGtTintTintPhysicalFunction.hpp | 4 +- .../EverLeTbigintTbigintPhysicalFunction.hpp | 4 +- .../Meos/EverLeTintTintPhysicalFunction.hpp | 4 +- .../EverLtTbigintTbigintPhysicalFunction.hpp | 4 +- .../Meos/EverLtTintTintPhysicalFunction.hpp | 4 +- .../EverNeTbigintTbigintPhysicalFunction.hpp | 4 +- .../Meos/EverNeTintTintPhysicalFunction.hpp | 4 +- .../Meos/TboolToTintPhysicalFunction.hpp | 42 ++++++++ ...AlwaysEqTbigintTbigintPhysicalFunction.cpp | 2 +- .../Meos/AlwaysEqTintTintPhysicalFunction.cpp | 2 +- ...AlwaysGeTbigintTbigintPhysicalFunction.cpp | 2 +- .../Meos/AlwaysGeTintTintPhysicalFunction.cpp | 2 +- ...AlwaysGtTbigintTbigintPhysicalFunction.cpp | 2 +- .../Meos/AlwaysGtTintTintPhysicalFunction.cpp | 2 +- ...AlwaysLeTbigintTbigintPhysicalFunction.cpp | 2 +- .../Meos/AlwaysLeTintTintPhysicalFunction.cpp | 2 +- ...AlwaysLtTbigintTbigintPhysicalFunction.cpp | 2 +- .../Meos/AlwaysLtTintTintPhysicalFunction.cpp | 2 +- ...AlwaysNeTbigintTbigintPhysicalFunction.cpp | 2 +- .../Meos/AlwaysNeTintTintPhysicalFunction.cpp | 2 +- .../src/Functions/Meos/CMakeLists.txt | 1 + .../EverEqTbigintTbigintPhysicalFunction.cpp | 2 +- .../Meos/EverEqTintTintPhysicalFunction.cpp | 2 +- .../EverGeTbigintTbigintPhysicalFunction.cpp | 2 +- .../Meos/EverGeTintTintPhysicalFunction.cpp | 2 +- .../EverGtTbigintTbigintPhysicalFunction.cpp | 2 +- .../Meos/EverGtTintTintPhysicalFunction.cpp | 2 +- .../EverLeTbigintTbigintPhysicalFunction.cpp | 2 +- .../Meos/EverLeTintTintPhysicalFunction.cpp | 2 +- .../EverLtTbigintTbigintPhysicalFunction.cpp | 2 +- .../Meos/EverLtTintTintPhysicalFunction.cpp | 2 +- .../EverNeTbigintTbigintPhysicalFunction.cpp | 2 +- .../Meos/EverNeTintTintPhysicalFunction.cpp | 2 +- .../Meos/TboolToTintPhysicalFunction.cpp | 88 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 3 +- .../src/AntlrSQLQueryPlanCreator.cpp | 27 +++++ 104 files changed, 844 insertions(+), 529 deletions(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TboolToTintLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TboolToTintLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TboolToTintPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TboolToTintPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.hpp index 46b63578c9..97cc441b0d 100644 --- a/nes-logical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `always_eq_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class AlwaysEqTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +class AlwaysEqTbigintTbigintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "AlwaysEqTbigintTfloat"; + static constexpr std::string_view NAME = "AlwaysEqTbigintTbigint"; - AlwaysEqTbigintTfloatLogicalFunction(LogicalFunction value1, + AlwaysEqTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTintTintLogicalFunction.hpp index 2e44a89f3a..c3a0bb5113 100644 --- a/nes-logical-operators/include/Functions/Meos/AlwaysEqTintTintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTintTintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `always_eq_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class AlwaysEqTintTfloatLogicalFunction : public LogicalFunctionConcept { +class AlwaysEqTintTintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "AlwaysEqTintTfloat"; + static constexpr std::string_view NAME = "AlwaysEqTintTint"; - AlwaysEqTintTfloatLogicalFunction(LogicalFunction value1, + AlwaysEqTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.hpp index 37f9d8e151..bce7503b9e 100644 --- a/nes-logical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `always_ge_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class AlwaysGeTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +class AlwaysGeTbigintTbigintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "AlwaysGeTbigintTfloat"; + static constexpr std::string_view NAME = "AlwaysGeTbigintTbigint"; - AlwaysGeTbigintTfloatLogicalFunction(LogicalFunction value1, + AlwaysGeTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeTintTintLogicalFunction.hpp index feb35315bc..86a2b57994 100644 --- a/nes-logical-operators/include/Functions/Meos/AlwaysGeTintTintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeTintTintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `always_ge_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class AlwaysGeTintTfloatLogicalFunction : public LogicalFunctionConcept { +class AlwaysGeTintTintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "AlwaysGeTintTfloat"; + static constexpr std::string_view NAME = "AlwaysGeTintTint"; - AlwaysGeTintTfloatLogicalFunction(LogicalFunction value1, + AlwaysGeTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.hpp index 48addeef95..a3f36fdd82 100644 --- a/nes-logical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `always_gt_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class AlwaysGtTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +class AlwaysGtTbigintTbigintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "AlwaysGtTbigintTfloat"; + static constexpr std::string_view NAME = "AlwaysGtTbigintTbigint"; - AlwaysGtTbigintTfloatLogicalFunction(LogicalFunction value1, + AlwaysGtTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtTintTintLogicalFunction.hpp index 51e6feaca9..09747a857c 100644 --- a/nes-logical-operators/include/Functions/Meos/AlwaysGtTintTintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtTintTintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `always_gt_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class AlwaysGtTintTfloatLogicalFunction : public LogicalFunctionConcept { +class AlwaysGtTintTintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "AlwaysGtTintTfloat"; + static constexpr std::string_view NAME = "AlwaysGtTintTint"; - AlwaysGtTintTfloatLogicalFunction(LogicalFunction value1, + AlwaysGtTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.hpp index 6c5c2998b6..7083b60b11 100644 --- a/nes-logical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `always_le_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class AlwaysLeTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +class AlwaysLeTbigintTbigintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "AlwaysLeTbigintTfloat"; + static constexpr std::string_view NAME = "AlwaysLeTbigintTbigint"; - AlwaysLeTbigintTfloatLogicalFunction(LogicalFunction value1, + AlwaysLeTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeTintTintLogicalFunction.hpp index 337148ee0e..3b93fac232 100644 --- a/nes-logical-operators/include/Functions/Meos/AlwaysLeTintTintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeTintTintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `always_le_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class AlwaysLeTintTfloatLogicalFunction : public LogicalFunctionConcept { +class AlwaysLeTintTintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "AlwaysLeTintTfloat"; + static constexpr std::string_view NAME = "AlwaysLeTintTint"; - AlwaysLeTintTfloatLogicalFunction(LogicalFunction value1, + AlwaysLeTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.hpp index bef92d195e..00a1ebe2c7 100644 --- a/nes-logical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `always_lt_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class AlwaysLtTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +class AlwaysLtTbigintTbigintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "AlwaysLtTbigintTfloat"; + static constexpr std::string_view NAME = "AlwaysLtTbigintTbigint"; - AlwaysLtTbigintTfloatLogicalFunction(LogicalFunction value1, + AlwaysLtTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtTintTintLogicalFunction.hpp index 0a9b5343c1..36ca1b4f50 100644 --- a/nes-logical-operators/include/Functions/Meos/AlwaysLtTintTintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtTintTintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `always_lt_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class AlwaysLtTintTfloatLogicalFunction : public LogicalFunctionConcept { +class AlwaysLtTintTintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "AlwaysLtTintTfloat"; + static constexpr std::string_view NAME = "AlwaysLtTintTint"; - AlwaysLtTintTfloatLogicalFunction(LogicalFunction value1, + AlwaysLtTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.hpp index 47801d4c53..c1bc0fee32 100644 --- a/nes-logical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `always_ne_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class AlwaysNeTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +class AlwaysNeTbigintTbigintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "AlwaysNeTbigintTfloat"; + static constexpr std::string_view NAME = "AlwaysNeTbigintTbigint"; - AlwaysNeTbigintTfloatLogicalFunction(LogicalFunction value1, + AlwaysNeTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTintTintLogicalFunction.hpp index 73341c243e..b0a8fcb573 100644 --- a/nes-logical-operators/include/Functions/Meos/AlwaysNeTintTintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTintTintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `always_ne_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class AlwaysNeTintTfloatLogicalFunction : public LogicalFunctionConcept { +class AlwaysNeTintTintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "AlwaysNeTintTfloat"; + static constexpr std::string_view NAME = "AlwaysNeTintTint"; - AlwaysNeTintTfloatLogicalFunction(LogicalFunction value1, + AlwaysNeTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTbigintTbigintLogicalFunction.hpp index 51cd3d91d3..017259ffdc 100644 --- a/nes-logical-operators/include/Functions/Meos/EverEqTbigintTbigintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/EverEqTbigintTbigintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `ever_eq_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class EverEqTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +class EverEqTbigintTbigintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "EverEqTbigintTfloat"; + static constexpr std::string_view NAME = "EverEqTbigintTbigint"; - EverEqTbigintTfloatLogicalFunction(LogicalFunction value1, + EverEqTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTintTintLogicalFunction.hpp index 7ec4f8404c..a644d244d8 100644 --- a/nes-logical-operators/include/Functions/Meos/EverEqTintTintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/EverEqTintTintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `ever_eq_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class EverEqTintTfloatLogicalFunction : public LogicalFunctionConcept { +class EverEqTintTintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "EverEqTintTfloat"; + static constexpr std::string_view NAME = "EverEqTintTint"; - EverEqTintTfloatLogicalFunction(LogicalFunction value1, + EverEqTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/EverGeTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeTbigintTbigintLogicalFunction.hpp index a69bc81c9e..37142f7d61 100644 --- a/nes-logical-operators/include/Functions/Meos/EverGeTbigintTbigintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/EverGeTbigintTbigintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `ever_ge_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class EverGeTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +class EverGeTbigintTbigintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "EverGeTbigintTfloat"; + static constexpr std::string_view NAME = "EverGeTbigintTbigint"; - EverGeTbigintTfloatLogicalFunction(LogicalFunction value1, + EverGeTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/EverGeTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeTintTintLogicalFunction.hpp index c3ecd8b446..3bd4885934 100644 --- a/nes-logical-operators/include/Functions/Meos/EverGeTintTintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/EverGeTintTintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `ever_ge_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class EverGeTintTfloatLogicalFunction : public LogicalFunctionConcept { +class EverGeTintTintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "EverGeTintTfloat"; + static constexpr std::string_view NAME = "EverGeTintTint"; - EverGeTintTfloatLogicalFunction(LogicalFunction value1, + EverGeTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/EverGtTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtTbigintTbigintLogicalFunction.hpp index cfba85ca24..837cf44504 100644 --- a/nes-logical-operators/include/Functions/Meos/EverGtTbigintTbigintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/EverGtTbigintTbigintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `ever_gt_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class EverGtTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +class EverGtTbigintTbigintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "EverGtTbigintTfloat"; + static constexpr std::string_view NAME = "EverGtTbigintTbigint"; - EverGtTbigintTfloatLogicalFunction(LogicalFunction value1, + EverGtTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/EverGtTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtTintTintLogicalFunction.hpp index 03d8dbfcdd..60eb612539 100644 --- a/nes-logical-operators/include/Functions/Meos/EverGtTintTintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/EverGtTintTintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `ever_gt_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class EverGtTintTfloatLogicalFunction : public LogicalFunctionConcept { +class EverGtTintTintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "EverGtTintTfloat"; + static constexpr std::string_view NAME = "EverGtTintTint"; - EverGtTintTfloatLogicalFunction(LogicalFunction value1, + EverGtTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/EverLeTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeTbigintTbigintLogicalFunction.hpp index 941fa3b879..eea6641179 100644 --- a/nes-logical-operators/include/Functions/Meos/EverLeTbigintTbigintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/EverLeTbigintTbigintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `ever_le_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class EverLeTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +class EverLeTbigintTbigintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "EverLeTbigintTfloat"; + static constexpr std::string_view NAME = "EverLeTbigintTbigint"; - EverLeTbigintTfloatLogicalFunction(LogicalFunction value1, + EverLeTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/EverLeTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeTintTintLogicalFunction.hpp index be4bf55c75..2d0fdadbb9 100644 --- a/nes-logical-operators/include/Functions/Meos/EverLeTintTintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/EverLeTintTintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `ever_le_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class EverLeTintTfloatLogicalFunction : public LogicalFunctionConcept { +class EverLeTintTintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "EverLeTintTfloat"; + static constexpr std::string_view NAME = "EverLeTintTint"; - EverLeTintTfloatLogicalFunction(LogicalFunction value1, + EverLeTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/EverLtTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtTbigintTbigintLogicalFunction.hpp index a7069b03a1..6fc6916421 100644 --- a/nes-logical-operators/include/Functions/Meos/EverLtTbigintTbigintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/EverLtTbigintTbigintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `ever_lt_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class EverLtTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +class EverLtTbigintTbigintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "EverLtTbigintTfloat"; + static constexpr std::string_view NAME = "EverLtTbigintTbigint"; - EverLtTbigintTfloatLogicalFunction(LogicalFunction value1, + EverLtTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/EverLtTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtTintTintLogicalFunction.hpp index 094d80a783..3167f87334 100644 --- a/nes-logical-operators/include/Functions/Meos/EverLtTintTintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/EverLtTintTintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `ever_lt_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class EverLtTintTfloatLogicalFunction : public LogicalFunctionConcept { +class EverLtTintTintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "EverLtTintTfloat"; + static constexpr std::string_view NAME = "EverLtTintTint"; - EverLtTintTfloatLogicalFunction(LogicalFunction value1, + EverLtTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTbigintTbigintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTbigintTbigintLogicalFunction.hpp index db0619a55b..94a696be48 100644 --- a/nes-logical-operators/include/Functions/Meos/EverNeTbigintTbigintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/EverNeTbigintTbigintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `ever_ne_tbigint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class EverNeTbigintTfloatLogicalFunction : public LogicalFunctionConcept { +class EverNeTbigintTbigintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "EverNeTbigintTfloat"; + static constexpr std::string_view NAME = "EverNeTbigintTbigint"; - EverNeTbigintTfloatLogicalFunction(LogicalFunction value1, + EverNeTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTintTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTintTintLogicalFunction.hpp index ae4ac26264..6fa3556589 100644 --- a/nes-logical-operators/include/Functions/Meos/EverNeTintTintLogicalFunction.hpp +++ b/nes-logical-operators/include/Functions/Meos/EverNeTintTintLogicalFunction.hpp @@ -28,11 +28,11 @@ namespace NES { * `ever_ne_tint_tfloat`. Takes (value1:FLOAT64, value2:FLOAT64, ts:UINT64), * constructs two single-instant temporals, applies the comparison, and returns FLOAT64 (0.0/1.0). */ -class EverNeTintTfloatLogicalFunction : public LogicalFunctionConcept { +class EverNeTintTintLogicalFunction : public LogicalFunctionConcept { public: - static constexpr std::string_view NAME = "EverNeTintTfloat"; + static constexpr std::string_view NAME = "EverNeTintTint"; - EverNeTintTfloatLogicalFunction(LogicalFunction value1, + EverNeTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts); diff --git a/nes-logical-operators/include/Functions/Meos/TboolToTintLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TboolToTintLogicalFunction.hpp new file mode 100644 index 0000000000..08065ed414 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TboolToTintLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event tbool_to_tint: single-instant tbool cast to tint, result extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `tbool_to_tint`. Per-event scalar operator following the + * TemporalEDWithinGeometry pattern. + */ +class TboolToTintLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TboolToTint"; + + TboolToTintLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.cpp index 7ca05704e4..6cf3e70c08 100644 --- a/nes-logical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -AlwaysEqTbigintTfloatLogicalFunction::AlwaysEqTbigintTfloatLogicalFunction(LogicalFunction value1, +AlwaysEqTbigintTbigintLogicalFunction::AlwaysEqTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ AlwaysEqTbigintTfloatLogicalFunction::AlwaysEqTbigintTfloatLogicalFunction(Logic parameters.push_back(std::move(ts)); } -DataType AlwaysEqTbigintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType AlwaysEqTbigintTbigintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction AlwaysEqTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction AlwaysEqTbigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector AlwaysEqTbigintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector AlwaysEqTbigintTbigintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction AlwaysEqTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction AlwaysEqTbigintTbigintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "AlwaysEqTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "AlwaysEqTbigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view AlwaysEqTbigintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view AlwaysEqTbigintTbigintLogicalFunction::getType() const { return NAME; } -bool AlwaysEqTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool AlwaysEqTbigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string AlwaysEqTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string AlwaysEqTbigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string AlwaysEqTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbo return fmt::format("{}({})", NAME, args); } -LogicalFunction AlwaysEqTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction AlwaysEqTbigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction AlwaysEqTbigintTfloatLogicalFunction::withInferredDataType(const return withChildren(newChildren); } -SerializableFunction AlwaysEqTbigintTfloatLogicalFunction::serialize() const +SerializableFunction AlwaysEqTbigintTbigintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction AlwaysEqTbigintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTbigintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTbigintTbigintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "AlwaysEqTbigintTfloatLogicalFunction requires 3 children but got {}", + "AlwaysEqTbigintTbigintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return AlwaysEqTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return AlwaysEqTbigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTintTintLogicalFunction.cpp index 4cdcffdd64..0fefb0d570 100644 --- a/nes-logical-operators/src/Functions/Meos/AlwaysEqTintTintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTintTintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -AlwaysEqTintTfloatLogicalFunction::AlwaysEqTintTfloatLogicalFunction(LogicalFunction value1, +AlwaysEqTintTintLogicalFunction::AlwaysEqTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ AlwaysEqTintTfloatLogicalFunction::AlwaysEqTintTfloatLogicalFunction(LogicalFunc parameters.push_back(std::move(ts)); } -DataType AlwaysEqTintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType AlwaysEqTintTintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction AlwaysEqTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction AlwaysEqTintTintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector AlwaysEqTintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector AlwaysEqTintTintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction AlwaysEqTintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction AlwaysEqTintTintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "AlwaysEqTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "AlwaysEqTintTintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view AlwaysEqTintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view AlwaysEqTintTintLogicalFunction::getType() const { return NAME; } -bool AlwaysEqTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool AlwaysEqTintTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string AlwaysEqTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string AlwaysEqTintTintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string AlwaysEqTintTfloatLogicalFunction::explain(ExplainVerbosity verbosit return fmt::format("{}({})", NAME, args); } -LogicalFunction AlwaysEqTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction AlwaysEqTintTintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction AlwaysEqTintTfloatLogicalFunction::withInferredDataType(const Sc return withChildren(newChildren); } -SerializableFunction AlwaysEqTintTfloatLogicalFunction::serialize() const +SerializableFunction AlwaysEqTintTintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction AlwaysEqTintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTintTintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "AlwaysEqTintTfloatLogicalFunction requires 3 children but got {}", + "AlwaysEqTintTintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return AlwaysEqTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return AlwaysEqTintTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.cpp index b97bd4c734..fb013e891c 100644 --- a/nes-logical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -AlwaysGeTbigintTfloatLogicalFunction::AlwaysGeTbigintTfloatLogicalFunction(LogicalFunction value1, +AlwaysGeTbigintTbigintLogicalFunction::AlwaysGeTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ AlwaysGeTbigintTfloatLogicalFunction::AlwaysGeTbigintTfloatLogicalFunction(Logic parameters.push_back(std::move(ts)); } -DataType AlwaysGeTbigintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType AlwaysGeTbigintTbigintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction AlwaysGeTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction AlwaysGeTbigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector AlwaysGeTbigintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector AlwaysGeTbigintTbigintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction AlwaysGeTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction AlwaysGeTbigintTbigintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "AlwaysGeTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "AlwaysGeTbigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view AlwaysGeTbigintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view AlwaysGeTbigintTbigintLogicalFunction::getType() const { return NAME; } -bool AlwaysGeTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool AlwaysGeTbigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string AlwaysGeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string AlwaysGeTbigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string AlwaysGeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbo return fmt::format("{}({})", NAME, args); } -LogicalFunction AlwaysGeTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction AlwaysGeTbigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction AlwaysGeTbigintTfloatLogicalFunction::withInferredDataType(const return withChildren(newChildren); } -SerializableFunction AlwaysGeTbigintTfloatLogicalFunction::serialize() const +SerializableFunction AlwaysGeTbigintTbigintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction AlwaysGeTbigintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeTbigintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeTbigintTbigintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "AlwaysGeTbigintTfloatLogicalFunction requires 3 children but got {}", + "AlwaysGeTbigintTbigintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return AlwaysGeTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return AlwaysGeTbigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeTintTintLogicalFunction.cpp index fb4f6f2a8e..7029bd2e0d 100644 --- a/nes-logical-operators/src/Functions/Meos/AlwaysGeTintTintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeTintTintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -AlwaysGeTintTfloatLogicalFunction::AlwaysGeTintTfloatLogicalFunction(LogicalFunction value1, +AlwaysGeTintTintLogicalFunction::AlwaysGeTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ AlwaysGeTintTfloatLogicalFunction::AlwaysGeTintTfloatLogicalFunction(LogicalFunc parameters.push_back(std::move(ts)); } -DataType AlwaysGeTintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType AlwaysGeTintTintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction AlwaysGeTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction AlwaysGeTintTintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector AlwaysGeTintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector AlwaysGeTintTintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction AlwaysGeTintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction AlwaysGeTintTintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "AlwaysGeTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "AlwaysGeTintTintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view AlwaysGeTintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view AlwaysGeTintTintLogicalFunction::getType() const { return NAME; } -bool AlwaysGeTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool AlwaysGeTintTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string AlwaysGeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string AlwaysGeTintTintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string AlwaysGeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosit return fmt::format("{}({})", NAME, args); } -LogicalFunction AlwaysGeTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction AlwaysGeTintTintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction AlwaysGeTintTfloatLogicalFunction::withInferredDataType(const Sc return withChildren(newChildren); } -SerializableFunction AlwaysGeTintTfloatLogicalFunction::serialize() const +SerializableFunction AlwaysGeTintTintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction AlwaysGeTintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeTintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeTintTintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "AlwaysGeTintTfloatLogicalFunction requires 3 children but got {}", + "AlwaysGeTintTintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return AlwaysGeTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return AlwaysGeTintTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.cpp index 794de5ab88..5f6522a5e8 100644 --- a/nes-logical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -AlwaysGtTbigintTfloatLogicalFunction::AlwaysGtTbigintTfloatLogicalFunction(LogicalFunction value1, +AlwaysGtTbigintTbigintLogicalFunction::AlwaysGtTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ AlwaysGtTbigintTfloatLogicalFunction::AlwaysGtTbigintTfloatLogicalFunction(Logic parameters.push_back(std::move(ts)); } -DataType AlwaysGtTbigintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType AlwaysGtTbigintTbigintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction AlwaysGtTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction AlwaysGtTbigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector AlwaysGtTbigintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector AlwaysGtTbigintTbigintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction AlwaysGtTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction AlwaysGtTbigintTbigintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "AlwaysGtTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "AlwaysGtTbigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view AlwaysGtTbigintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view AlwaysGtTbigintTbigintLogicalFunction::getType() const { return NAME; } -bool AlwaysGtTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool AlwaysGtTbigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string AlwaysGtTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string AlwaysGtTbigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string AlwaysGtTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbo return fmt::format("{}({})", NAME, args); } -LogicalFunction AlwaysGtTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction AlwaysGtTbigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction AlwaysGtTbigintTfloatLogicalFunction::withInferredDataType(const return withChildren(newChildren); } -SerializableFunction AlwaysGtTbigintTfloatLogicalFunction::serialize() const +SerializableFunction AlwaysGtTbigintTbigintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction AlwaysGtTbigintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtTbigintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtTbigintTbigintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "AlwaysGtTbigintTfloatLogicalFunction requires 3 children but got {}", + "AlwaysGtTbigintTbigintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return AlwaysGtTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return AlwaysGtTbigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtTintTintLogicalFunction.cpp index 09c753625b..ac6ddd3730 100644 --- a/nes-logical-operators/src/Functions/Meos/AlwaysGtTintTintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtTintTintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -AlwaysGtTintTfloatLogicalFunction::AlwaysGtTintTfloatLogicalFunction(LogicalFunction value1, +AlwaysGtTintTintLogicalFunction::AlwaysGtTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ AlwaysGtTintTfloatLogicalFunction::AlwaysGtTintTfloatLogicalFunction(LogicalFunc parameters.push_back(std::move(ts)); } -DataType AlwaysGtTintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType AlwaysGtTintTintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction AlwaysGtTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction AlwaysGtTintTintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector AlwaysGtTintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector AlwaysGtTintTintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction AlwaysGtTintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction AlwaysGtTintTintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "AlwaysGtTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "AlwaysGtTintTintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view AlwaysGtTintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view AlwaysGtTintTintLogicalFunction::getType() const { return NAME; } -bool AlwaysGtTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool AlwaysGtTintTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string AlwaysGtTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string AlwaysGtTintTintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string AlwaysGtTintTfloatLogicalFunction::explain(ExplainVerbosity verbosit return fmt::format("{}({})", NAME, args); } -LogicalFunction AlwaysGtTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction AlwaysGtTintTintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction AlwaysGtTintTfloatLogicalFunction::withInferredDataType(const Sc return withChildren(newChildren); } -SerializableFunction AlwaysGtTintTfloatLogicalFunction::serialize() const +SerializableFunction AlwaysGtTintTintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction AlwaysGtTintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtTintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtTintTintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "AlwaysGtTintTfloatLogicalFunction requires 3 children but got {}", + "AlwaysGtTintTintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return AlwaysGtTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return AlwaysGtTintTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.cpp index 33641ce8e0..0a306d9fb5 100644 --- a/nes-logical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -AlwaysLeTbigintTfloatLogicalFunction::AlwaysLeTbigintTfloatLogicalFunction(LogicalFunction value1, +AlwaysLeTbigintTbigintLogicalFunction::AlwaysLeTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ AlwaysLeTbigintTfloatLogicalFunction::AlwaysLeTbigintTfloatLogicalFunction(Logic parameters.push_back(std::move(ts)); } -DataType AlwaysLeTbigintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType AlwaysLeTbigintTbigintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction AlwaysLeTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction AlwaysLeTbigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector AlwaysLeTbigintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector AlwaysLeTbigintTbigintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction AlwaysLeTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction AlwaysLeTbigintTbigintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "AlwaysLeTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "AlwaysLeTbigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view AlwaysLeTbigintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view AlwaysLeTbigintTbigintLogicalFunction::getType() const { return NAME; } -bool AlwaysLeTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool AlwaysLeTbigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string AlwaysLeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string AlwaysLeTbigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string AlwaysLeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbo return fmt::format("{}({})", NAME, args); } -LogicalFunction AlwaysLeTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction AlwaysLeTbigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction AlwaysLeTbigintTfloatLogicalFunction::withInferredDataType(const return withChildren(newChildren); } -SerializableFunction AlwaysLeTbigintTfloatLogicalFunction::serialize() const +SerializableFunction AlwaysLeTbigintTbigintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction AlwaysLeTbigintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeTbigintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeTbigintTbigintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "AlwaysLeTbigintTfloatLogicalFunction requires 3 children but got {}", + "AlwaysLeTbigintTbigintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return AlwaysLeTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return AlwaysLeTbigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeTintTintLogicalFunction.cpp index 356758b0cc..f07de54f8e 100644 --- a/nes-logical-operators/src/Functions/Meos/AlwaysLeTintTintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeTintTintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -AlwaysLeTintTfloatLogicalFunction::AlwaysLeTintTfloatLogicalFunction(LogicalFunction value1, +AlwaysLeTintTintLogicalFunction::AlwaysLeTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ AlwaysLeTintTfloatLogicalFunction::AlwaysLeTintTfloatLogicalFunction(LogicalFunc parameters.push_back(std::move(ts)); } -DataType AlwaysLeTintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType AlwaysLeTintTintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction AlwaysLeTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction AlwaysLeTintTintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector AlwaysLeTintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector AlwaysLeTintTintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction AlwaysLeTintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction AlwaysLeTintTintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "AlwaysLeTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "AlwaysLeTintTintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view AlwaysLeTintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view AlwaysLeTintTintLogicalFunction::getType() const { return NAME; } -bool AlwaysLeTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool AlwaysLeTintTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string AlwaysLeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string AlwaysLeTintTintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string AlwaysLeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosit return fmt::format("{}({})", NAME, args); } -LogicalFunction AlwaysLeTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction AlwaysLeTintTintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction AlwaysLeTintTfloatLogicalFunction::withInferredDataType(const Sc return withChildren(newChildren); } -SerializableFunction AlwaysLeTintTfloatLogicalFunction::serialize() const +SerializableFunction AlwaysLeTintTintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction AlwaysLeTintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeTintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeTintTintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "AlwaysLeTintTfloatLogicalFunction requires 3 children but got {}", + "AlwaysLeTintTintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return AlwaysLeTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return AlwaysLeTintTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.cpp index 38e012aebc..5077bf2a48 100644 --- a/nes-logical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -AlwaysLtTbigintTfloatLogicalFunction::AlwaysLtTbigintTfloatLogicalFunction(LogicalFunction value1, +AlwaysLtTbigintTbigintLogicalFunction::AlwaysLtTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ AlwaysLtTbigintTfloatLogicalFunction::AlwaysLtTbigintTfloatLogicalFunction(Logic parameters.push_back(std::move(ts)); } -DataType AlwaysLtTbigintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType AlwaysLtTbigintTbigintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction AlwaysLtTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction AlwaysLtTbigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector AlwaysLtTbigintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector AlwaysLtTbigintTbigintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction AlwaysLtTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction AlwaysLtTbigintTbigintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "AlwaysLtTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "AlwaysLtTbigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view AlwaysLtTbigintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view AlwaysLtTbigintTbigintLogicalFunction::getType() const { return NAME; } -bool AlwaysLtTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool AlwaysLtTbigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string AlwaysLtTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string AlwaysLtTbigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string AlwaysLtTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbo return fmt::format("{}({})", NAME, args); } -LogicalFunction AlwaysLtTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction AlwaysLtTbigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction AlwaysLtTbigintTfloatLogicalFunction::withInferredDataType(const return withChildren(newChildren); } -SerializableFunction AlwaysLtTbigintTfloatLogicalFunction::serialize() const +SerializableFunction AlwaysLtTbigintTbigintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction AlwaysLtTbigintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtTbigintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtTbigintTbigintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "AlwaysLtTbigintTfloatLogicalFunction requires 3 children but got {}", + "AlwaysLtTbigintTbigintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return AlwaysLtTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return AlwaysLtTbigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtTintTintLogicalFunction.cpp index e88014e58e..42cc4f81c5 100644 --- a/nes-logical-operators/src/Functions/Meos/AlwaysLtTintTintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtTintTintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -AlwaysLtTintTfloatLogicalFunction::AlwaysLtTintTfloatLogicalFunction(LogicalFunction value1, +AlwaysLtTintTintLogicalFunction::AlwaysLtTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ AlwaysLtTintTfloatLogicalFunction::AlwaysLtTintTfloatLogicalFunction(LogicalFunc parameters.push_back(std::move(ts)); } -DataType AlwaysLtTintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType AlwaysLtTintTintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction AlwaysLtTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction AlwaysLtTintTintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector AlwaysLtTintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector AlwaysLtTintTintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction AlwaysLtTintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction AlwaysLtTintTintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "AlwaysLtTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "AlwaysLtTintTintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view AlwaysLtTintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view AlwaysLtTintTintLogicalFunction::getType() const { return NAME; } -bool AlwaysLtTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool AlwaysLtTintTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string AlwaysLtTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string AlwaysLtTintTintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string AlwaysLtTintTfloatLogicalFunction::explain(ExplainVerbosity verbosit return fmt::format("{}({})", NAME, args); } -LogicalFunction AlwaysLtTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction AlwaysLtTintTintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction AlwaysLtTintTfloatLogicalFunction::withInferredDataType(const Sc return withChildren(newChildren); } -SerializableFunction AlwaysLtTintTfloatLogicalFunction::serialize() const +SerializableFunction AlwaysLtTintTintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction AlwaysLtTintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtTintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtTintTintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "AlwaysLtTintTfloatLogicalFunction requires 3 children but got {}", + "AlwaysLtTintTintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return AlwaysLtTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return AlwaysLtTintTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.cpp index 9a9eda9b8d..3d2affb41d 100644 --- a/nes-logical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -AlwaysNeTbigintTfloatLogicalFunction::AlwaysNeTbigintTfloatLogicalFunction(LogicalFunction value1, +AlwaysNeTbigintTbigintLogicalFunction::AlwaysNeTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ AlwaysNeTbigintTfloatLogicalFunction::AlwaysNeTbigintTfloatLogicalFunction(Logic parameters.push_back(std::move(ts)); } -DataType AlwaysNeTbigintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType AlwaysNeTbigintTbigintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction AlwaysNeTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction AlwaysNeTbigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector AlwaysNeTbigintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector AlwaysNeTbigintTbigintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction AlwaysNeTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction AlwaysNeTbigintTbigintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "AlwaysNeTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "AlwaysNeTbigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view AlwaysNeTbigintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view AlwaysNeTbigintTbigintLogicalFunction::getType() const { return NAME; } -bool AlwaysNeTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool AlwaysNeTbigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string AlwaysNeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string AlwaysNeTbigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string AlwaysNeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbo return fmt::format("{}({})", NAME, args); } -LogicalFunction AlwaysNeTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction AlwaysNeTbigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction AlwaysNeTbigintTfloatLogicalFunction::withInferredDataType(const return withChildren(newChildren); } -SerializableFunction AlwaysNeTbigintTfloatLogicalFunction::serialize() const +SerializableFunction AlwaysNeTbigintTbigintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction AlwaysNeTbigintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTbigintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTbigintTbigintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "AlwaysNeTbigintTfloatLogicalFunction requires 3 children but got {}", + "AlwaysNeTbigintTbigintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return AlwaysNeTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return AlwaysNeTbigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTintTintLogicalFunction.cpp index 83bcedc991..4908cd1db6 100644 --- a/nes-logical-operators/src/Functions/Meos/AlwaysNeTintTintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTintTintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -AlwaysNeTintTfloatLogicalFunction::AlwaysNeTintTfloatLogicalFunction(LogicalFunction value1, +AlwaysNeTintTintLogicalFunction::AlwaysNeTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ AlwaysNeTintTfloatLogicalFunction::AlwaysNeTintTfloatLogicalFunction(LogicalFunc parameters.push_back(std::move(ts)); } -DataType AlwaysNeTintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType AlwaysNeTintTintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction AlwaysNeTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction AlwaysNeTintTintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector AlwaysNeTintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector AlwaysNeTintTintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction AlwaysNeTintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction AlwaysNeTintTintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "AlwaysNeTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "AlwaysNeTintTintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view AlwaysNeTintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view AlwaysNeTintTintLogicalFunction::getType() const { return NAME; } -bool AlwaysNeTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool AlwaysNeTintTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string AlwaysNeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string AlwaysNeTintTintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string AlwaysNeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosit return fmt::format("{}({})", NAME, args); } -LogicalFunction AlwaysNeTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction AlwaysNeTintTintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction AlwaysNeTintTfloatLogicalFunction::withInferredDataType(const Sc return withChildren(newChildren); } -SerializableFunction AlwaysNeTintTfloatLogicalFunction::serialize() const +SerializableFunction AlwaysNeTintTintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction AlwaysNeTintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTintTintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "AlwaysNeTintTfloatLogicalFunction requires 3 children but got {}", + "AlwaysNeTintTintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return AlwaysNeTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return AlwaysNeTintTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 376f53b53c..0f5902cc58 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -245,3 +245,4 @@ add_plugin(TltFloatTfloat LogicalFunction nes-logical-operators TltFloatTfloatLo add_plugin(TltTintInt LogicalFunction nes-logical-operators TltTintIntLogicalFunction.cpp) add_plugin(TltIntTint LogicalFunction nes-logical-operators TltIntTintLogicalFunction.cpp) add_plugin(TltTemporalTemporal LogicalFunction nes-logical-operators TltTemporalTemporalLogicalFunction.cpp) +add_plugin(TboolToTint LogicalFunction nes-logical-operators TboolToTintLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTbigintTbigintLogicalFunction.cpp index aff2bb3796..82f535cc7b 100644 --- a/nes-logical-operators/src/Functions/Meos/EverEqTbigintTbigintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/EverEqTbigintTbigintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -EverEqTbigintTfloatLogicalFunction::EverEqTbigintTfloatLogicalFunction(LogicalFunction value1, +EverEqTbigintTbigintLogicalFunction::EverEqTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ EverEqTbigintTfloatLogicalFunction::EverEqTbigintTfloatLogicalFunction(LogicalFu parameters.push_back(std::move(ts)); } -DataType EverEqTbigintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType EverEqTbigintTbigintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction EverEqTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction EverEqTbigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector EverEqTbigintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector EverEqTbigintTbigintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction EverEqTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction EverEqTbigintTbigintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "EverEqTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "EverEqTbigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view EverEqTbigintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view EverEqTbigintTbigintLogicalFunction::getType() const { return NAME; } -bool EverEqTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool EverEqTbigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string EverEqTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string EverEqTbigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string EverEqTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosi return fmt::format("{}({})", NAME, args); } -LogicalFunction EverEqTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction EverEqTbigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction EverEqTbigintTfloatLogicalFunction::withInferredDataType(const S return withChildren(newChildren); } -SerializableFunction EverEqTbigintTfloatLogicalFunction::serialize() const +SerializableFunction EverEqTbigintTbigintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction EverEqTbigintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTbigintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTbigintTbigintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "EverEqTbigintTfloatLogicalFunction requires 3 children but got {}", + "EverEqTbigintTbigintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return EverEqTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return EverEqTbigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTintTintLogicalFunction.cpp index 36354c8967..fa5f4387f3 100644 --- a/nes-logical-operators/src/Functions/Meos/EverEqTintTintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/EverEqTintTintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -EverEqTintTfloatLogicalFunction::EverEqTintTfloatLogicalFunction(LogicalFunction value1, +EverEqTintTintLogicalFunction::EverEqTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ EverEqTintTfloatLogicalFunction::EverEqTintTfloatLogicalFunction(LogicalFunction parameters.push_back(std::move(ts)); } -DataType EverEqTintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType EverEqTintTintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction EverEqTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction EverEqTintTintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector EverEqTintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector EverEqTintTintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction EverEqTintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction EverEqTintTintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "EverEqTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "EverEqTintTintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view EverEqTintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view EverEqTintTintLogicalFunction::getType() const { return NAME; } -bool EverEqTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool EverEqTintTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string EverEqTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string EverEqTintTintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string EverEqTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) return fmt::format("{}({})", NAME, args); } -LogicalFunction EverEqTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction EverEqTintTintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction EverEqTintTfloatLogicalFunction::withInferredDataType(const Sche return withChildren(newChildren); } -SerializableFunction EverEqTintTfloatLogicalFunction::serialize() const +SerializableFunction EverEqTintTintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction EverEqTintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTintTintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "EverEqTintTfloatLogicalFunction requires 3 children but got {}", + "EverEqTintTintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return EverEqTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return EverEqTintTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeTbigintTbigintLogicalFunction.cpp index 124252845f..c97dae065c 100644 --- a/nes-logical-operators/src/Functions/Meos/EverGeTbigintTbigintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/EverGeTbigintTbigintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -EverGeTbigintTfloatLogicalFunction::EverGeTbigintTfloatLogicalFunction(LogicalFunction value1, +EverGeTbigintTbigintLogicalFunction::EverGeTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ EverGeTbigintTfloatLogicalFunction::EverGeTbigintTfloatLogicalFunction(LogicalFu parameters.push_back(std::move(ts)); } -DataType EverGeTbigintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType EverGeTbigintTbigintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction EverGeTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction EverGeTbigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector EverGeTbigintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector EverGeTbigintTbigintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction EverGeTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction EverGeTbigintTbigintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "EverGeTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "EverGeTbigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view EverGeTbigintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view EverGeTbigintTbigintLogicalFunction::getType() const { return NAME; } -bool EverGeTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool EverGeTbigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string EverGeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string EverGeTbigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string EverGeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosi return fmt::format("{}({})", NAME, args); } -LogicalFunction EverGeTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction EverGeTbigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction EverGeTbigintTfloatLogicalFunction::withInferredDataType(const S return withChildren(newChildren); } -SerializableFunction EverGeTbigintTfloatLogicalFunction::serialize() const +SerializableFunction EverGeTbigintTbigintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction EverGeTbigintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeTbigintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeTbigintTbigintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "EverGeTbigintTfloatLogicalFunction requires 3 children but got {}", + "EverGeTbigintTbigintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return EverGeTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return EverGeTbigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeTintTintLogicalFunction.cpp index 40a41a043e..af5b8871aa 100644 --- a/nes-logical-operators/src/Functions/Meos/EverGeTintTintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/EverGeTintTintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -EverGeTintTfloatLogicalFunction::EverGeTintTfloatLogicalFunction(LogicalFunction value1, +EverGeTintTintLogicalFunction::EverGeTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ EverGeTintTfloatLogicalFunction::EverGeTintTfloatLogicalFunction(LogicalFunction parameters.push_back(std::move(ts)); } -DataType EverGeTintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType EverGeTintTintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction EverGeTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction EverGeTintTintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector EverGeTintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector EverGeTintTintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction EverGeTintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction EverGeTintTintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "EverGeTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "EverGeTintTintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view EverGeTintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view EverGeTintTintLogicalFunction::getType() const { return NAME; } -bool EverGeTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool EverGeTintTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string EverGeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string EverGeTintTintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string EverGeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) return fmt::format("{}({})", NAME, args); } -LogicalFunction EverGeTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction EverGeTintTintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction EverGeTintTfloatLogicalFunction::withInferredDataType(const Sche return withChildren(newChildren); } -SerializableFunction EverGeTintTfloatLogicalFunction::serialize() const +SerializableFunction EverGeTintTintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction EverGeTintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeTintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGeTintTintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "EverGeTintTfloatLogicalFunction requires 3 children but got {}", + "EverGeTintTintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return EverGeTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return EverGeTintTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtTbigintTbigintLogicalFunction.cpp index 1c3161aadd..53bbcb2c10 100644 --- a/nes-logical-operators/src/Functions/Meos/EverGtTbigintTbigintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/EverGtTbigintTbigintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -EverGtTbigintTfloatLogicalFunction::EverGtTbigintTfloatLogicalFunction(LogicalFunction value1, +EverGtTbigintTbigintLogicalFunction::EverGtTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ EverGtTbigintTfloatLogicalFunction::EverGtTbigintTfloatLogicalFunction(LogicalFu parameters.push_back(std::move(ts)); } -DataType EverGtTbigintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType EverGtTbigintTbigintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction EverGtTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction EverGtTbigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector EverGtTbigintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector EverGtTbigintTbigintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction EverGtTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction EverGtTbigintTbigintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "EverGtTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "EverGtTbigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view EverGtTbigintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view EverGtTbigintTbigintLogicalFunction::getType() const { return NAME; } -bool EverGtTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool EverGtTbigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string EverGtTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string EverGtTbigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string EverGtTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosi return fmt::format("{}({})", NAME, args); } -LogicalFunction EverGtTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction EverGtTbigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction EverGtTbigintTfloatLogicalFunction::withInferredDataType(const S return withChildren(newChildren); } -SerializableFunction EverGtTbigintTfloatLogicalFunction::serialize() const +SerializableFunction EverGtTbigintTbigintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction EverGtTbigintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtTbigintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtTbigintTbigintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "EverGtTbigintTfloatLogicalFunction requires 3 children but got {}", + "EverGtTbigintTbigintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return EverGtTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return EverGtTbigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtTintTintLogicalFunction.cpp index 5c58d78fda..962f12e4cb 100644 --- a/nes-logical-operators/src/Functions/Meos/EverGtTintTintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/EverGtTintTintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -EverGtTintTfloatLogicalFunction::EverGtTintTfloatLogicalFunction(LogicalFunction value1, +EverGtTintTintLogicalFunction::EverGtTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ EverGtTintTfloatLogicalFunction::EverGtTintTfloatLogicalFunction(LogicalFunction parameters.push_back(std::move(ts)); } -DataType EverGtTintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType EverGtTintTintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction EverGtTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction EverGtTintTintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector EverGtTintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector EverGtTintTintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction EverGtTintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction EverGtTintTintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "EverGtTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "EverGtTintTintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view EverGtTintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view EverGtTintTintLogicalFunction::getType() const { return NAME; } -bool EverGtTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool EverGtTintTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string EverGtTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string EverGtTintTintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string EverGtTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) return fmt::format("{}({})", NAME, args); } -LogicalFunction EverGtTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction EverGtTintTintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction EverGtTintTfloatLogicalFunction::withInferredDataType(const Sche return withChildren(newChildren); } -SerializableFunction EverGtTintTfloatLogicalFunction::serialize() const +SerializableFunction EverGtTintTintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction EverGtTintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtTintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverGtTintTintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "EverGtTintTfloatLogicalFunction requires 3 children but got {}", + "EverGtTintTintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return EverGtTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return EverGtTintTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeTbigintTbigintLogicalFunction.cpp index 6a0d2b51ad..5232e0d088 100644 --- a/nes-logical-operators/src/Functions/Meos/EverLeTbigintTbigintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/EverLeTbigintTbigintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -EverLeTbigintTfloatLogicalFunction::EverLeTbigintTfloatLogicalFunction(LogicalFunction value1, +EverLeTbigintTbigintLogicalFunction::EverLeTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ EverLeTbigintTfloatLogicalFunction::EverLeTbigintTfloatLogicalFunction(LogicalFu parameters.push_back(std::move(ts)); } -DataType EverLeTbigintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType EverLeTbigintTbigintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction EverLeTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction EverLeTbigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector EverLeTbigintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector EverLeTbigintTbigintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction EverLeTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction EverLeTbigintTbigintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "EverLeTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "EverLeTbigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view EverLeTbigintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view EverLeTbigintTbigintLogicalFunction::getType() const { return NAME; } -bool EverLeTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool EverLeTbigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string EverLeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string EverLeTbigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string EverLeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosi return fmt::format("{}({})", NAME, args); } -LogicalFunction EverLeTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction EverLeTbigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction EverLeTbigintTfloatLogicalFunction::withInferredDataType(const S return withChildren(newChildren); } -SerializableFunction EverLeTbigintTfloatLogicalFunction::serialize() const +SerializableFunction EverLeTbigintTbigintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction EverLeTbigintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeTbigintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeTbigintTbigintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "EverLeTbigintTfloatLogicalFunction requires 3 children but got {}", + "EverLeTbigintTbigintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return EverLeTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return EverLeTbigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeTintTintLogicalFunction.cpp index 079b5d64c0..71d801b989 100644 --- a/nes-logical-operators/src/Functions/Meos/EverLeTintTintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/EverLeTintTintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -EverLeTintTfloatLogicalFunction::EverLeTintTfloatLogicalFunction(LogicalFunction value1, +EverLeTintTintLogicalFunction::EverLeTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ EverLeTintTfloatLogicalFunction::EverLeTintTfloatLogicalFunction(LogicalFunction parameters.push_back(std::move(ts)); } -DataType EverLeTintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType EverLeTintTintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction EverLeTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction EverLeTintTintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector EverLeTintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector EverLeTintTintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction EverLeTintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction EverLeTintTintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "EverLeTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "EverLeTintTintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view EverLeTintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view EverLeTintTintLogicalFunction::getType() const { return NAME; } -bool EverLeTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool EverLeTintTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string EverLeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string EverLeTintTintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string EverLeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) return fmt::format("{}({})", NAME, args); } -LogicalFunction EverLeTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction EverLeTintTintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction EverLeTintTfloatLogicalFunction::withInferredDataType(const Sche return withChildren(newChildren); } -SerializableFunction EverLeTintTfloatLogicalFunction::serialize() const +SerializableFunction EverLeTintTintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction EverLeTintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeTintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLeTintTintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "EverLeTintTfloatLogicalFunction requires 3 children but got {}", + "EverLeTintTintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return EverLeTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return EverLeTintTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtTbigintTbigintLogicalFunction.cpp index 715a85cc22..f91f384d07 100644 --- a/nes-logical-operators/src/Functions/Meos/EverLtTbigintTbigintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/EverLtTbigintTbigintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -EverLtTbigintTfloatLogicalFunction::EverLtTbigintTfloatLogicalFunction(LogicalFunction value1, +EverLtTbigintTbigintLogicalFunction::EverLtTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ EverLtTbigintTfloatLogicalFunction::EverLtTbigintTfloatLogicalFunction(LogicalFu parameters.push_back(std::move(ts)); } -DataType EverLtTbigintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType EverLtTbigintTbigintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction EverLtTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction EverLtTbigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector EverLtTbigintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector EverLtTbigintTbigintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction EverLtTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction EverLtTbigintTbigintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "EverLtTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "EverLtTbigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view EverLtTbigintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view EverLtTbigintTbigintLogicalFunction::getType() const { return NAME; } -bool EverLtTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool EverLtTbigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string EverLtTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string EverLtTbigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string EverLtTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosi return fmt::format("{}({})", NAME, args); } -LogicalFunction EverLtTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction EverLtTbigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction EverLtTbigintTfloatLogicalFunction::withInferredDataType(const S return withChildren(newChildren); } -SerializableFunction EverLtTbigintTfloatLogicalFunction::serialize() const +SerializableFunction EverLtTbigintTbigintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction EverLtTbigintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtTbigintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtTbigintTbigintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "EverLtTbigintTfloatLogicalFunction requires 3 children but got {}", + "EverLtTbigintTbigintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return EverLtTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return EverLtTbigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtTintTintLogicalFunction.cpp index 39aa65da2f..1f47506dc4 100644 --- a/nes-logical-operators/src/Functions/Meos/EverLtTintTintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/EverLtTintTintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -EverLtTintTfloatLogicalFunction::EverLtTintTfloatLogicalFunction(LogicalFunction value1, +EverLtTintTintLogicalFunction::EverLtTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ EverLtTintTfloatLogicalFunction::EverLtTintTfloatLogicalFunction(LogicalFunction parameters.push_back(std::move(ts)); } -DataType EverLtTintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType EverLtTintTintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction EverLtTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction EverLtTintTintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector EverLtTintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector EverLtTintTintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction EverLtTintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction EverLtTintTintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "EverLtTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "EverLtTintTintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view EverLtTintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view EverLtTintTintLogicalFunction::getType() const { return NAME; } -bool EverLtTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool EverLtTintTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string EverLtTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string EverLtTintTintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string EverLtTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) return fmt::format("{}({})", NAME, args); } -LogicalFunction EverLtTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction EverLtTintTintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction EverLtTintTfloatLogicalFunction::withInferredDataType(const Sche return withChildren(newChildren); } -SerializableFunction EverLtTintTfloatLogicalFunction::serialize() const +SerializableFunction EverLtTintTintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction EverLtTintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtTintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverLtTintTintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "EverLtTintTfloatLogicalFunction requires 3 children but got {}", + "EverLtTintTintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return EverLtTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return EverLtTintTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTbigintTbigintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTbigintTbigintLogicalFunction.cpp index c4bdbe9e42..1561ed36fe 100644 --- a/nes-logical-operators/src/Functions/Meos/EverNeTbigintTbigintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/EverNeTbigintTbigintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -EverNeTbigintTfloatLogicalFunction::EverNeTbigintTfloatLogicalFunction(LogicalFunction value1, +EverNeTbigintTbigintLogicalFunction::EverNeTbigintTbigintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ EverNeTbigintTfloatLogicalFunction::EverNeTbigintTfloatLogicalFunction(LogicalFu parameters.push_back(std::move(ts)); } -DataType EverNeTbigintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType EverNeTbigintTbigintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction EverNeTbigintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction EverNeTbigintTbigintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector EverNeTbigintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector EverNeTbigintTbigintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction EverNeTbigintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction EverNeTbigintTbigintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "EverNeTbigintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "EverNeTbigintTbigintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view EverNeTbigintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view EverNeTbigintTbigintLogicalFunction::getType() const { return NAME; } -bool EverNeTbigintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool EverNeTbigintTbigintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string EverNeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string EverNeTbigintTbigintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string EverNeTbigintTfloatLogicalFunction::explain(ExplainVerbosity verbosi return fmt::format("{}({})", NAME, args); } -LogicalFunction EverNeTbigintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction EverNeTbigintTbigintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction EverNeTbigintTfloatLogicalFunction::withInferredDataType(const S return withChildren(newChildren); } -SerializableFunction EverNeTbigintTfloatLogicalFunction::serialize() const +SerializableFunction EverNeTbigintTbigintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction EverNeTbigintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTbigintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTbigintTbigintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "EverNeTbigintTfloatLogicalFunction requires 3 children but got {}", + "EverNeTbigintTbigintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return EverNeTbigintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return EverNeTbigintTbigintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTintTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTintTintLogicalFunction.cpp index 5a73940882..f6562fdcae 100644 --- a/nes-logical-operators/src/Functions/Meos/EverNeTintTintLogicalFunction.cpp +++ b/nes-logical-operators/src/Functions/Meos/EverNeTintTintLogicalFunction.cpp @@ -12,7 +12,7 @@ limitations under the License. */ -#include +#include #include #include @@ -26,7 +26,7 @@ namespace NES { -EverNeTintTfloatLogicalFunction::EverNeTintTfloatLogicalFunction(LogicalFunction value1, +EverNeTintTintLogicalFunction::EverNeTintTintLogicalFunction(LogicalFunction value1, LogicalFunction value2, LogicalFunction ts) : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) @@ -37,31 +37,31 @@ EverNeTintTfloatLogicalFunction::EverNeTintTfloatLogicalFunction(LogicalFunction parameters.push_back(std::move(ts)); } -DataType EverNeTintTfloatLogicalFunction::getDataType() const { return dataType; } +DataType EverNeTintTintLogicalFunction::getDataType() const { return dataType; } -LogicalFunction EverNeTintTfloatLogicalFunction::withDataType(const DataType& newDataType) const +LogicalFunction EverNeTintTintLogicalFunction::withDataType(const DataType& newDataType) const { auto copy = *this; copy.dataType = newDataType; return copy; } -std::vector EverNeTintTfloatLogicalFunction::getChildren() const { return parameters; } +std::vector EverNeTintTintLogicalFunction::getChildren() const { return parameters; } -LogicalFunction EverNeTintTfloatLogicalFunction::withChildren(const std::vector& children) const +LogicalFunction EverNeTintTintLogicalFunction::withChildren(const std::vector& children) const { - PRECONDITION(children.size() == 3, "EverNeTintTfloatLogicalFunction requires 3 children, but got {}", children.size()); + PRECONDITION(children.size() == 3, "EverNeTintTintLogicalFunction requires 3 children, but got {}", children.size()); auto copy = *this; copy.parameters = children; return copy; } -std::string_view EverNeTintTfloatLogicalFunction::getType() const { return NAME; } +std::string_view EverNeTintTintLogicalFunction::getType() const { return NAME; } -bool EverNeTintTfloatLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +bool EverNeTintTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { - if (const auto* other = dynamic_cast(&rhs)) + if (const auto* other = dynamic_cast(&rhs)) return parameters == other->parameters; return false; } -std::string EverNeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) const +std::string EverNeTintTintLogicalFunction::explain(ExplainVerbosity verbosity) const { std::string args; for (size_t index = 0; index < parameters.size(); ++index) { @@ -71,7 +71,7 @@ std::string EverNeTintTfloatLogicalFunction::explain(ExplainVerbosity verbosity) return fmt::format("{}({})", NAME, args); } -LogicalFunction EverNeTintTfloatLogicalFunction::withInferredDataType(const Schema& schema) const +LogicalFunction EverNeTintTintLogicalFunction::withInferredDataType(const Schema& schema) const { std::vector newChildren; newChildren.reserve(parameters.size()); @@ -80,7 +80,7 @@ LogicalFunction EverNeTintTfloatLogicalFunction::withInferredDataType(const Sche return withChildren(newChildren); } -SerializableFunction EverNeTintTfloatLogicalFunction::serialize() const +SerializableFunction EverNeTintTintLogicalFunction::serialize() const { SerializableFunction proto; proto.set_function_type(std::string(NAME)); @@ -90,16 +90,16 @@ SerializableFunction EverNeTintTfloatLogicalFunction::serialize() const return proto; } -LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTintTfloatLogicalFunction( +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTintTintLogicalFunction( LogicalFunctionRegistryArguments arguments) { PRECONDITION(arguments.children.size() == 3, - "EverNeTintTfloatLogicalFunction requires 3 children but got {}", + "EverNeTintTintLogicalFunction requires 3 children but got {}", arguments.children.size()); auto arg0 = std::move(arguments.children[0]); auto arg1 = std::move(arguments.children[1]); auto arg2 = std::move(arguments.children[2]); - return EverNeTintTfloatLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); + return EverNeTintTintLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); } } // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TboolToTintLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TboolToTintLogicalFunction.cpp new file mode 100644 index 0000000000..7ffe35b195 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TboolToTintLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TboolToTintLogicalFunction::TboolToTintLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TboolToTintLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TboolToTintLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TboolToTintLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TboolToTintLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TboolToTintLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TboolToTintLogicalFunction::getType() const { return NAME; } + +bool TboolToTintLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TboolToTintLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TboolToTintLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TboolToTintLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTboolToTintLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TboolToTintLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TboolToTintLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.hpp index d03da809cf..5a2d1af1fb 100644 --- a/nes-physical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class AlwaysEqTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class AlwaysEqTbigintTbigintPhysicalFunction : public PhysicalFunctionConcept { public: - AlwaysEqTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + AlwaysEqTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTintTintPhysicalFunction.hpp index de9dea6e9a..207be5cf00 100644 --- a/nes-physical-operators/include/Functions/Meos/AlwaysEqTintTintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTintTintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class AlwaysEqTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class AlwaysEqTintTintPhysicalFunction : public PhysicalFunctionConcept { public: - AlwaysEqTintTfloatPhysicalFunction(PhysicalFunction value1Function, + AlwaysEqTintTintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.hpp index 8d166e1d18..6a63d58931 100644 --- a/nes-physical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class AlwaysGeTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class AlwaysGeTbigintTbigintPhysicalFunction : public PhysicalFunctionConcept { public: - AlwaysGeTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + AlwaysGeTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeTintTintPhysicalFunction.hpp index 7ec07a1a5e..7a2bcdc4e2 100644 --- a/nes-physical-operators/include/Functions/Meos/AlwaysGeTintTintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeTintTintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class AlwaysGeTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class AlwaysGeTintTintPhysicalFunction : public PhysicalFunctionConcept { public: - AlwaysGeTintTfloatPhysicalFunction(PhysicalFunction value1Function, + AlwaysGeTintTintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.hpp index 85322c8557..978b07d5ef 100644 --- a/nes-physical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class AlwaysGtTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class AlwaysGtTbigintTbigintPhysicalFunction : public PhysicalFunctionConcept { public: - AlwaysGtTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + AlwaysGtTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtTintTintPhysicalFunction.hpp index ee47873039..b4eb7237d7 100644 --- a/nes-physical-operators/include/Functions/Meos/AlwaysGtTintTintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtTintTintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class AlwaysGtTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class AlwaysGtTintTintPhysicalFunction : public PhysicalFunctionConcept { public: - AlwaysGtTintTfloatPhysicalFunction(PhysicalFunction value1Function, + AlwaysGtTintTintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.hpp index bbaf3b2281..bb133b7e6c 100644 --- a/nes-physical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class AlwaysLeTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class AlwaysLeTbigintTbigintPhysicalFunction : public PhysicalFunctionConcept { public: - AlwaysLeTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + AlwaysLeTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeTintTintPhysicalFunction.hpp index 38e8137ff1..da439e5478 100644 --- a/nes-physical-operators/include/Functions/Meos/AlwaysLeTintTintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeTintTintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class AlwaysLeTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class AlwaysLeTintTintPhysicalFunction : public PhysicalFunctionConcept { public: - AlwaysLeTintTfloatPhysicalFunction(PhysicalFunction value1Function, + AlwaysLeTintTintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.hpp index ce560fd1c2..944add04ff 100644 --- a/nes-physical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class AlwaysLtTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class AlwaysLtTbigintTbigintPhysicalFunction : public PhysicalFunctionConcept { public: - AlwaysLtTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + AlwaysLtTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtTintTintPhysicalFunction.hpp index ae9d97fd84..4e0136a66c 100644 --- a/nes-physical-operators/include/Functions/Meos/AlwaysLtTintTintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtTintTintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class AlwaysLtTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class AlwaysLtTintTintPhysicalFunction : public PhysicalFunctionConcept { public: - AlwaysLtTintTfloatPhysicalFunction(PhysicalFunction value1Function, + AlwaysLtTintTintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.hpp index acf3065538..b07e1473ac 100644 --- a/nes-physical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class AlwaysNeTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class AlwaysNeTbigintTbigintPhysicalFunction : public PhysicalFunctionConcept { public: - AlwaysNeTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + AlwaysNeTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTintTintPhysicalFunction.hpp index a2822cb82c..782e592249 100644 --- a/nes-physical-operators/include/Functions/Meos/AlwaysNeTintTintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTintTintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class AlwaysNeTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class AlwaysNeTintTintPhysicalFunction : public PhysicalFunctionConcept { public: - AlwaysNeTintTfloatPhysicalFunction(PhysicalFunction value1Function, + AlwaysNeTintTintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.hpp index feaa66970f..18cb76960a 100644 --- a/nes-physical-operators/include/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class EverEqTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class EverEqTbigintTbigintPhysicalFunction : public PhysicalFunctionConcept { public: - EverEqTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + EverEqTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTintTintPhysicalFunction.hpp index 77d542711b..68631d0f34 100644 --- a/nes-physical-operators/include/Functions/Meos/EverEqTintTintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/EverEqTintTintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class EverEqTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class EverEqTintTintPhysicalFunction : public PhysicalFunctionConcept { public: - EverEqTintTfloatPhysicalFunction(PhysicalFunction value1Function, + EverEqTintTintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.hpp index c14497db81..6244735062 100644 --- a/nes-physical-operators/include/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class EverGeTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class EverGeTbigintTbigintPhysicalFunction : public PhysicalFunctionConcept { public: - EverGeTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + EverGeTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/EverGeTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeTintTintPhysicalFunction.hpp index e0f449ef14..830083a5e1 100644 --- a/nes-physical-operators/include/Functions/Meos/EverGeTintTintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/EverGeTintTintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class EverGeTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class EverGeTintTintPhysicalFunction : public PhysicalFunctionConcept { public: - EverGeTintTfloatPhysicalFunction(PhysicalFunction value1Function, + EverGeTintTintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.hpp index 7137cd04c1..be6deeb4c3 100644 --- a/nes-physical-operators/include/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class EverGtTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class EverGtTbigintTbigintPhysicalFunction : public PhysicalFunctionConcept { public: - EverGtTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + EverGtTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/EverGtTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtTintTintPhysicalFunction.hpp index 6bed523848..696a35d40b 100644 --- a/nes-physical-operators/include/Functions/Meos/EverGtTintTintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/EverGtTintTintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class EverGtTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class EverGtTintTintPhysicalFunction : public PhysicalFunctionConcept { public: - EverGtTintTfloatPhysicalFunction(PhysicalFunction value1Function, + EverGtTintTintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.hpp index f11bc3c16c..40eeceaf8d 100644 --- a/nes-physical-operators/include/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class EverLeTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class EverLeTbigintTbigintPhysicalFunction : public PhysicalFunctionConcept { public: - EverLeTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + EverLeTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/EverLeTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeTintTintPhysicalFunction.hpp index 15a53b5bdf..474f05f496 100644 --- a/nes-physical-operators/include/Functions/Meos/EverLeTintTintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/EverLeTintTintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class EverLeTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class EverLeTintTintPhysicalFunction : public PhysicalFunctionConcept { public: - EverLeTintTfloatPhysicalFunction(PhysicalFunction value1Function, + EverLeTintTintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.hpp index bb25e34d09..b34d196a70 100644 --- a/nes-physical-operators/include/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class EverLtTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class EverLtTbigintTbigintPhysicalFunction : public PhysicalFunctionConcept { public: - EverLtTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + EverLtTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/EverLtTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtTintTintPhysicalFunction.hpp index b483fd4afc..7c86434ab6 100644 --- a/nes-physical-operators/include/Functions/Meos/EverLtTintTintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/EverLtTintTintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class EverLtTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class EverLtTintTintPhysicalFunction : public PhysicalFunctionConcept { public: - EverLtTintTfloatPhysicalFunction(PhysicalFunction value1Function, + EverLtTintTintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.hpp index 406dd8b083..f6fe0c3bc3 100644 --- a/nes-physical-operators/include/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class EverNeTbigintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class EverNeTbigintTbigintPhysicalFunction : public PhysicalFunctionConcept { public: - EverNeTbigintTfloatPhysicalFunction(PhysicalFunction value1Function, + EverNeTbigintTbigintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTintTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTintTintPhysicalFunction.hpp index 070a0b888a..3dfabb9e8d 100644 --- a/nes-physical-operators/include/Functions/Meos/EverNeTintTintPhysicalFunction.hpp +++ b/nes-physical-operators/include/Functions/Meos/EverNeTintTintPhysicalFunction.hpp @@ -28,9 +28,9 @@ namespace NES { * * Generated by tools/codegen/codegen_nebula.py. */ -class EverNeTintTfloatPhysicalFunction : public PhysicalFunctionConcept { +class EverNeTintTintPhysicalFunction : public PhysicalFunctionConcept { public: - EverNeTintTfloatPhysicalFunction(PhysicalFunction value1Function, + EverNeTintTintPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction value2Function, PhysicalFunction tsFunction); diff --git a/nes-physical-operators/include/Functions/Meos/TboolToTintPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TboolToTintPhysicalFunction.hpp new file mode 100644 index 0000000000..473cc7f507 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TboolToTintPhysicalFunction.hpp @@ -0,0 +1,42 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Physical operator for `tbool_to_tint`. + * + * Per-event tbool_to_tint: single-instant tbool cast to tint, result extracted -> double. + * + * Generated by tools/codegen/codegen_nebula.py. + */ +class TboolToTintPhysicalFunction : public PhysicalFunctionConcept { +public: + TboolToTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector parameterFunctions; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.cpp index bf44057630..3bbe7fcaba 100644 --- a/nes-physical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTbigintTbigintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal AlwaysEqTbigintTbigintPhysicalFunction::execute(const Record& record, Are if (!temp1) return 0.0; Temporal* temp2 = tbigint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = always_eq_tbigint_tbigint(temp1, temp2); + int r = always_eq_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTintTintPhysicalFunction.cpp index e1c238acdd..d60ec80d9b 100644 --- a/nes-physical-operators/src/Functions/Meos/AlwaysEqTintTintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTintTintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal AlwaysEqTintTintPhysicalFunction::execute(const Record& record, ArenaRef& if (!temp1) return 0.0; Temporal* temp2 = tint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = always_eq_tint_tint(temp1, temp2); + int r = always_eq_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.cpp index f810dcceb8..8b6fab2658 100644 --- a/nes-physical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeTbigintTbigintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal AlwaysGeTbigintTbigintPhysicalFunction::execute(const Record& record, Are if (!temp1) return 0.0; Temporal* temp2 = tbigint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = always_ge_tbigint_tbigint(temp1, temp2); + int r = always_ge_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeTintTintPhysicalFunction.cpp index 13abe21605..eaad3fcdb3 100644 --- a/nes-physical-operators/src/Functions/Meos/AlwaysGeTintTintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeTintTintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal AlwaysGeTintTintPhysicalFunction::execute(const Record& record, ArenaRef& if (!temp1) return 0.0; Temporal* temp2 = tint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = always_ge_tint_tint(temp1, temp2); + int r = always_ge_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.cpp index 06b7e7ee23..0bcde3a315 100644 --- a/nes-physical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtTbigintTbigintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal AlwaysGtTbigintTbigintPhysicalFunction::execute(const Record& record, Are if (!temp1) return 0.0; Temporal* temp2 = tbigint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = always_gt_tbigint_tbigint(temp1, temp2); + int r = always_gt_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtTintTintPhysicalFunction.cpp index e9f1824a0c..139248ab9f 100644 --- a/nes-physical-operators/src/Functions/Meos/AlwaysGtTintTintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtTintTintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal AlwaysGtTintTintPhysicalFunction::execute(const Record& record, ArenaRef& if (!temp1) return 0.0; Temporal* temp2 = tint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = always_gt_tint_tint(temp1, temp2); + int r = always_gt_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.cpp index d2cb50c242..508776aa71 100644 --- a/nes-physical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeTbigintTbigintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal AlwaysLeTbigintTbigintPhysicalFunction::execute(const Record& record, Are if (!temp1) return 0.0; Temporal* temp2 = tbigint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = always_le_tbigint_tbigint(temp1, temp2); + int r = always_le_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeTintTintPhysicalFunction.cpp index 974b4caaca..2c95ea51f2 100644 --- a/nes-physical-operators/src/Functions/Meos/AlwaysLeTintTintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeTintTintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal AlwaysLeTintTintPhysicalFunction::execute(const Record& record, ArenaRef& if (!temp1) return 0.0; Temporal* temp2 = tint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = always_le_tint_tint(temp1, temp2); + int r = always_le_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.cpp index 6c704c5f0b..9eee745294 100644 --- a/nes-physical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtTbigintTbigintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal AlwaysLtTbigintTbigintPhysicalFunction::execute(const Record& record, Are if (!temp1) return 0.0; Temporal* temp2 = tbigint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = always_lt_tbigint_tbigint(temp1, temp2); + int r = always_lt_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtTintTintPhysicalFunction.cpp index 5649cde140..38f0a04581 100644 --- a/nes-physical-operators/src/Functions/Meos/AlwaysLtTintTintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtTintTintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal AlwaysLtTintTintPhysicalFunction::execute(const Record& record, ArenaRef& if (!temp1) return 0.0; Temporal* temp2 = tint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = always_lt_tint_tint(temp1, temp2); + int r = always_lt_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.cpp index 1ea159194d..23b78e2cf3 100644 --- a/nes-physical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTbigintTbigintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal AlwaysNeTbigintTbigintPhysicalFunction::execute(const Record& record, Are if (!temp1) return 0.0; Temporal* temp2 = tbigint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = always_ne_tbigint_tbigint(temp1, temp2); + int r = always_ne_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTintTintPhysicalFunction.cpp index 8ca2ce0681..470fcd6322 100644 --- a/nes-physical-operators/src/Functions/Meos/AlwaysNeTintTintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTintTintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal AlwaysNeTintTintPhysicalFunction::execute(const Record& record, ArenaRef& if (!temp1) return 0.0; Temporal* temp2 = tint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = always_ne_tint_tint(temp1, temp2); + int r = always_ne_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 1329e88057..5224235981 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -244,4 +244,5 @@ add_plugin(TltFloatTfloat PhysicalFunction nes-physical-operators TltFloatTfloat add_plugin(TltTintInt PhysicalFunction nes-physical-operators TltTintIntPhysicalFunction.cpp) add_plugin(TltIntTint PhysicalFunction nes-physical-operators TltIntTintPhysicalFunction.cpp) add_plugin(TltTemporalTemporal PhysicalFunction nes-physical-operators TltTemporalTemporalPhysicalFunction.cpp) +add_plugin(TboolToTint PhysicalFunction nes-physical-operators TboolToTintPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.cpp index 6c74c63431..1af1b3e958 100644 --- a/nes-physical-operators/src/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/EverEqTbigintTbigintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal EverEqTbigintTbigintPhysicalFunction::execute(const Record& record, Arena if (!temp1) return 0.0; Temporal* temp2 = tbigint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = ever_eq_tbigint_tbigint(temp1, temp2); + int r = ever_eq_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTintTintPhysicalFunction.cpp index caa3038238..238f23e8fb 100644 --- a/nes-physical-operators/src/Functions/Meos/EverEqTintTintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/EverEqTintTintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal EverEqTintTintPhysicalFunction::execute(const Record& record, ArenaRef& a if (!temp1) return 0.0; Temporal* temp2 = tint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = ever_eq_tint_tint(temp1, temp2); + int r = ever_eq_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.cpp index 09f5309356..5135f72e3a 100644 --- a/nes-physical-operators/src/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/EverGeTbigintTbigintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal EverGeTbigintTbigintPhysicalFunction::execute(const Record& record, Arena if (!temp1) return 0.0; Temporal* temp2 = tbigint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = ever_ge_tbigint_tbigint(temp1, temp2); + int r = ever_ge_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/EverGeTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeTintTintPhysicalFunction.cpp index 7a82536015..1f499cff83 100644 --- a/nes-physical-operators/src/Functions/Meos/EverGeTintTintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/EverGeTintTintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal EverGeTintTintPhysicalFunction::execute(const Record& record, ArenaRef& a if (!temp1) return 0.0; Temporal* temp2 = tint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = ever_ge_tint_tint(temp1, temp2); + int r = ever_ge_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.cpp index 93d5cb0a0b..929d78d591 100644 --- a/nes-physical-operators/src/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/EverGtTbigintTbigintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal EverGtTbigintTbigintPhysicalFunction::execute(const Record& record, Arena if (!temp1) return 0.0; Temporal* temp2 = tbigint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = ever_gt_tbigint_tbigint(temp1, temp2); + int r = ever_gt_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/EverGtTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtTintTintPhysicalFunction.cpp index b5a76c9e8d..778f6fdd73 100644 --- a/nes-physical-operators/src/Functions/Meos/EverGtTintTintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/EverGtTintTintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal EverGtTintTintPhysicalFunction::execute(const Record& record, ArenaRef& a if (!temp1) return 0.0; Temporal* temp2 = tint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = ever_gt_tint_tint(temp1, temp2); + int r = ever_gt_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.cpp index f0492bd755..96d137f209 100644 --- a/nes-physical-operators/src/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/EverLeTbigintTbigintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal EverLeTbigintTbigintPhysicalFunction::execute(const Record& record, Arena if (!temp1) return 0.0; Temporal* temp2 = tbigint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = ever_le_tbigint_tbigint(temp1, temp2); + int r = ever_le_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/EverLeTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeTintTintPhysicalFunction.cpp index 26f58ed26b..41e17ee5bb 100644 --- a/nes-physical-operators/src/Functions/Meos/EverLeTintTintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/EverLeTintTintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal EverLeTintTintPhysicalFunction::execute(const Record& record, ArenaRef& a if (!temp1) return 0.0; Temporal* temp2 = tint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = ever_le_tint_tint(temp1, temp2); + int r = ever_le_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.cpp index 31e6ac9ee5..99866fcec8 100644 --- a/nes-physical-operators/src/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/EverLtTbigintTbigintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal EverLtTbigintTbigintPhysicalFunction::execute(const Record& record, Arena if (!temp1) return 0.0; Temporal* temp2 = tbigint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = ever_lt_tbigint_tbigint(temp1, temp2); + int r = ever_lt_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/EverLtTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtTintTintPhysicalFunction.cpp index 584074e9f2..372f292528 100644 --- a/nes-physical-operators/src/Functions/Meos/EverLtTintTintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/EverLtTintTintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal EverLtTintTintPhysicalFunction::execute(const Record& record, ArenaRef& a if (!temp1) return 0.0; Temporal* temp2 = tint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = ever_lt_tint_tint(temp1, temp2); + int r = ever_lt_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.cpp index 1709c60c40..b14946f449 100644 --- a/nes-physical-operators/src/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/EverNeTbigintTbigintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal EverNeTbigintTbigintPhysicalFunction::execute(const Record& record, Arena if (!temp1) return 0.0; Temporal* temp2 = tbigint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = ever_ne_tbigint_tbigint(temp1, temp2); + int r = ever_ne_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTintTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTintTintPhysicalFunction.cpp index 168fc072c8..ecb0836662 100644 --- a/nes-physical-operators/src/Functions/Meos/EverNeTintTintPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/EverNeTintTintPhysicalFunction.cpp @@ -67,7 +67,7 @@ VarVal EverNeTintTintPhysicalFunction::execute(const Record& record, ArenaRef& a if (!temp1) return 0.0; Temporal* temp2 = tint_in(wkt2.c_str()); if (!temp2) { free(temp1); return 0.0; } - int r = ever_ne_tint_tint(temp1, temp2); + int r = ever_ne_temporal_temporal(temp1, temp2); free(temp1); free(temp2); return static_cast(r); diff --git a/nes-physical-operators/src/Functions/Meos/TboolToTintPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TboolToTintPhysicalFunction.cpp new file mode 100644 index 0000000000..7f20b301ad --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TboolToTintPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +TboolToTintPhysicalFunction::TboolToTintPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + parameterFunctions.reserve(2); + parameterFunctions.push_back(std::move(valueFunction)); + parameterFunctions.push_back(std::move(tsFunction)); +} + +VarVal TboolToTintPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + std::vector parameterValues; + parameterValues.reserve(parameterFunctions.size()); + for (const auto& function : parameterFunctions) + parameterValues.emplace_back(function.execute(record, arena)); + + auto value = parameterValues[0].cast>(); + auto ts = parameterValues[1].cast>(); + + const auto result = nautilus::invoke( + +[](double v, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = fmt::format("{}@{}", (v != 0.0 ? "t" : "f"), ts_str); + Temporal* temp = tbool_in(wkt.c_str()); + if (!temp) return 0.0; + Temporal* res = tbool_to_tint(temp); + free(temp); + if (!res) return 0.0; + int r = tint_start_value(res); + free(res); + return static_cast(r); + } catch (const std::exception&) { return 0.0; } + }, + value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTboolToTintPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TboolToTintPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + auto arg0 = std::move(arguments.childFunctions[0]); + auto arg1 = std::move(arguments.childFunctions[1]); + return TboolToTintPhysicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index cb28c14e3f..ce613ef640 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT; sinkClause: INTO sink (',' sink)*; @@ -715,6 +715,7 @@ TLT_FLOAT_TFLOAT: 'TLT_FLOAT_TFLOAT' | 'tlt_float_tfloat'; TLT_TINT_INT: 'TLT_TINT_INT' | 'tlt_tint_int'; TLT_INT_TINT: 'TLT_INT_TINT' | 'tlt_int_tint'; TLT_TEMPORAL_TEMPORAL: 'TLT_TEMPORAL_TEMPORAL' | 'tlt_temporal_temporal'; +TBOOL_TO_TINT: 'TBOOL_TO_TINT' | 'tbool_to_tint'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index f9544a8eae..fc61ea38d2 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -296,6 +296,7 @@ #include #include #include +#include #include #include #include @@ -7575,6 +7576,32 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont }} break; /* END CODEGEN PARSER GLUE: TLT_TEMPORAL_TEMPORAL */ + /* BEGIN CODEGEN PARSER GLUE: TBOOL_TO_TINT */ + case AntlrSQLLexer::TBOOL_TO_TINT: + { + const auto argCount = context->expression().size(); + if (argCount != 2) + throw InvalidQuerySyntax("TBOOL_TO_TINT requires exactly 2 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + helpers.top().functionBuilder.emplace_back(TboolToTintLogicalFunction(a0, a1)); + } + break; + /* END CODEGEN PARSER GLUE: TBOOL_TO_TINT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From c0f2c9734e13b6b50fb3debea2401d883bebe397 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Sun, 14 Jun 2026 06:01:40 +0200 Subject: [PATCH 42/86] feat(meos): add ttext scalar comparison NES operators (W93) Adds 28 per-event NES scalar operators covering ever/always/teq/tne comparisons between a single-instant ttext and a text literal, in both argument orders: EVER_{EQ,NE,GE,GT,LE,LT}_{TTEXT_TEXT,TEXT_TTEXT}, ALWAYS_{EQ,NE,GE,GT,LE,LT}_{TTEXT_TEXT,TEXT_TTEXT}, TEQ/TNE_{TTEXT_TEXT,TEXT_TTEXT}. Each operator takes (textValue:VARCHAR, textRef:VARCHAR, ts:UINT64), builds a single-instant ttext via ttext_in and converts the reference string to a text datum via cstring_to_text, then delegates to the corresponding MEOS ever_*/always_*/teq_*/tne_* kernel. ever/always variants return FLOAT64 1.0/0.0 directly; teq/tne extract the tbool result via tbool_start_value. Wired across logical/physical CMakeLists, AntlrSQL.g4 functionName rule and lexer section, and AntlrSQLQueryPlanCreator.cpp. --- .../Meos/AlwaysEqTextTtextLogicalFunction.hpp | 43 + .../Meos/AlwaysEqTtextTextLogicalFunction.hpp | 43 + .../Meos/AlwaysGeTextTtextLogicalFunction.hpp | 43 + .../Meos/AlwaysGeTtextTextLogicalFunction.hpp | 43 + .../Meos/AlwaysGtTextTtextLogicalFunction.hpp | 43 + .../Meos/AlwaysGtTtextTextLogicalFunction.hpp | 43 + .../Meos/AlwaysLeTextTtextLogicalFunction.hpp | 43 + .../Meos/AlwaysLeTtextTextLogicalFunction.hpp | 43 + .../Meos/AlwaysLtTextTtextLogicalFunction.hpp | 43 + .../Meos/AlwaysLtTtextTextLogicalFunction.hpp | 43 + .../Meos/AlwaysNeTextTtextLogicalFunction.hpp | 43 + .../Meos/AlwaysNeTtextTextLogicalFunction.hpp | 43 + .../Meos/EverEqTextTtextLogicalFunction.hpp | 43 + .../Meos/EverEqTtextTextLogicalFunction.hpp | 43 + .../Meos/EverGeTextTtextLogicalFunction.hpp | 43 + .../Meos/EverGeTtextTextLogicalFunction.hpp | 43 + .../Meos/EverGtTextTtextLogicalFunction.hpp | 43 + .../Meos/EverGtTtextTextLogicalFunction.hpp | 43 + .../Meos/EverLeTextTtextLogicalFunction.hpp | 43 + .../Meos/EverLeTtextTextLogicalFunction.hpp | 43 + .../Meos/EverLtTextTtextLogicalFunction.hpp | 43 + .../Meos/EverLtTtextTextLogicalFunction.hpp | 43 + .../Meos/EverNeTextTtextLogicalFunction.hpp | 43 + .../Meos/EverNeTtextTextLogicalFunction.hpp | 43 + .../Meos/TeqTextTtextLogicalFunction.hpp | 43 + .../Meos/TeqTtextTextLogicalFunction.hpp | 43 + .../Meos/TneTextTtextLogicalFunction.hpp | 43 + .../Meos/TneTtextTextLogicalFunction.hpp | 43 + .../Meos/AlwaysEqTextTtextLogicalFunction.cpp | 93 ++ .../Meos/AlwaysEqTtextTextLogicalFunction.cpp | 93 ++ .../Meos/AlwaysGeTextTtextLogicalFunction.cpp | 93 ++ .../Meos/AlwaysGeTtextTextLogicalFunction.cpp | 93 ++ .../Meos/AlwaysGtTextTtextLogicalFunction.cpp | 93 ++ .../Meos/AlwaysGtTtextTextLogicalFunction.cpp | 93 ++ .../Meos/AlwaysLeTextTtextLogicalFunction.cpp | 93 ++ .../Meos/AlwaysLeTtextTextLogicalFunction.cpp | 93 ++ .../Meos/AlwaysLtTextTtextLogicalFunction.cpp | 93 ++ .../Meos/AlwaysLtTtextTextLogicalFunction.cpp | 93 ++ .../Meos/AlwaysNeTextTtextLogicalFunction.cpp | 93 ++ .../Meos/AlwaysNeTtextTextLogicalFunction.cpp | 93 ++ .../src/Functions/Meos/CMakeLists.txt | 28 + .../Meos/EverEqTextTtextLogicalFunction.cpp | 93 ++ .../Meos/EverEqTtextTextLogicalFunction.cpp | 93 ++ .../Meos/EverGeTextTtextLogicalFunction.cpp | 93 ++ .../Meos/EverGeTtextTextLogicalFunction.cpp | 93 ++ .../Meos/EverGtTextTtextLogicalFunction.cpp | 93 ++ .../Meos/EverGtTtextTextLogicalFunction.cpp | 93 ++ .../Meos/EverLeTextTtextLogicalFunction.cpp | 93 ++ .../Meos/EverLeTtextTextLogicalFunction.cpp | 93 ++ .../Meos/EverLtTextTtextLogicalFunction.cpp | 93 ++ .../Meos/EverLtTtextTextLogicalFunction.cpp | 93 ++ .../Meos/EverNeTextTtextLogicalFunction.cpp | 93 ++ .../Meos/EverNeTtextTextLogicalFunction.cpp | 93 ++ .../Meos/TeqTextTtextLogicalFunction.cpp | 93 ++ .../Meos/TeqTtextTextLogicalFunction.cpp | 93 ++ .../Meos/TneTextTtextLogicalFunction.cpp | 93 ++ .../Meos/TneTtextTextLogicalFunction.cpp | 93 ++ .../AlwaysEqTextTtextPhysicalFunction.hpp | 36 + .../AlwaysEqTtextTextPhysicalFunction.hpp | 36 + .../AlwaysGeTextTtextPhysicalFunction.hpp | 36 + .../AlwaysGeTtextTextPhysicalFunction.hpp | 36 + .../AlwaysGtTextTtextPhysicalFunction.hpp | 36 + .../AlwaysGtTtextTextPhysicalFunction.hpp | 36 + .../AlwaysLeTextTtextPhysicalFunction.hpp | 36 + .../AlwaysLeTtextTextPhysicalFunction.hpp | 36 + .../AlwaysLtTextTtextPhysicalFunction.hpp | 36 + .../AlwaysLtTtextTextPhysicalFunction.hpp | 36 + .../AlwaysNeTextTtextPhysicalFunction.hpp | 36 + .../AlwaysNeTtextTextPhysicalFunction.hpp | 36 + .../Meos/EverEqTextTtextPhysicalFunction.hpp | 36 + .../Meos/EverEqTtextTextPhysicalFunction.hpp | 36 + .../Meos/EverGeTextTtextPhysicalFunction.hpp | 36 + .../Meos/EverGeTtextTextPhysicalFunction.hpp | 36 + .../Meos/EverGtTextTtextPhysicalFunction.hpp | 36 + .../Meos/EverGtTtextTextPhysicalFunction.hpp | 36 + .../Meos/EverLeTextTtextPhysicalFunction.hpp | 36 + .../Meos/EverLeTtextTextPhysicalFunction.hpp | 36 + .../Meos/EverLtTextTtextPhysicalFunction.hpp | 36 + .../Meos/EverLtTtextTextPhysicalFunction.hpp | 36 + .../Meos/EverNeTextTtextPhysicalFunction.hpp | 36 + .../Meos/EverNeTtextTextPhysicalFunction.hpp | 36 + .../Meos/TeqTextTtextPhysicalFunction.hpp | 36 + .../Meos/TeqTtextTextPhysicalFunction.hpp | 36 + .../Meos/TneTextTtextPhysicalFunction.hpp | 36 + .../Meos/TneTtextTextPhysicalFunction.hpp | 36 + .../AlwaysEqTextTtextPhysicalFunction.cpp | 90 ++ .../AlwaysEqTtextTextPhysicalFunction.cpp | 90 ++ .../AlwaysGeTextTtextPhysicalFunction.cpp | 90 ++ .../AlwaysGeTtextTextPhysicalFunction.cpp | 90 ++ .../AlwaysGtTextTtextPhysicalFunction.cpp | 90 ++ .../AlwaysGtTtextTextPhysicalFunction.cpp | 90 ++ .../AlwaysLeTextTtextPhysicalFunction.cpp | 90 ++ .../AlwaysLeTtextTextPhysicalFunction.cpp | 90 ++ .../AlwaysLtTextTtextPhysicalFunction.cpp | 90 ++ .../AlwaysLtTtextTextPhysicalFunction.cpp | 90 ++ .../AlwaysNeTextTtextPhysicalFunction.cpp | 90 ++ .../AlwaysNeTtextTextPhysicalFunction.cpp | 90 ++ .../src/Functions/Meos/CMakeLists.txt | 28 + .../Meos/EverEqTextTtextPhysicalFunction.cpp | 90 ++ .../Meos/EverEqTtextTextPhysicalFunction.cpp | 90 ++ .../Meos/EverGeTextTtextPhysicalFunction.cpp | 90 ++ .../Meos/EverGeTtextTextPhysicalFunction.cpp | 90 ++ .../Meos/EverGtTextTtextPhysicalFunction.cpp | 90 ++ .../Meos/EverGtTtextTextPhysicalFunction.cpp | 90 ++ .../Meos/EverLeTextTtextPhysicalFunction.cpp | 90 ++ .../Meos/EverLeTtextTextPhysicalFunction.cpp | 90 ++ .../Meos/EverLtTextTtextPhysicalFunction.cpp | 90 ++ .../Meos/EverLtTtextTextPhysicalFunction.cpp | 90 ++ .../Meos/EverNeTextTtextPhysicalFunction.cpp | 90 ++ .../Meos/EverNeTtextTextPhysicalFunction.cpp | 90 ++ .../Meos/TeqTextTtextPhysicalFunction.cpp | 93 ++ .../Meos/TeqTtextTextPhysicalFunction.cpp | 93 ++ .../Meos/TneTextTtextPhysicalFunction.cpp | 93 ++ .../Meos/TneTtextTextPhysicalFunction.cpp | 93 ++ nes-sql-parser/AntlrSQL.g4 | 30 +- .../src/AntlrSQLQueryPlanCreator.cpp | 840 ++++++++++++++++++ 116 files changed, 8273 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGeTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGeTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGtTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysGtTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLeTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLeTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLtTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysLtTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGeTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGeTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGtTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverGtTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLeTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLeTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLtTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverLtTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TeqTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TeqTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TneTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TneTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGeTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGeTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGtTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysGtTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLeTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLeTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLtTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysLtTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGeTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGeTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGtTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverGtTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLeTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLeTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLtTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverLtTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TeqTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TeqTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TneTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TneTtextTextLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGeTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGeTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGtTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysGtTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLeTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLeTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLtTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysLtTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGeTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGeTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGtTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverGtTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLeTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLeTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLtTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverLtTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TeqTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TeqTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TneTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TneTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGeTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGeTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGtTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysGtTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLeTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLeTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLtTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysLtTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGeTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGeTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGtTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverGtTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLeTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLeTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLtTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverLtTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TeqTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TeqTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TneTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TneTtextTextPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..17ecec6cf6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class AlwaysEqTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTextTtext"; + + AlwaysEqTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..819dc5fcba --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class AlwaysEqTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTtextText"; + + AlwaysEqTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..81b80ff5bb --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class AlwaysGeTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGeTextTtext"; + + AlwaysGeTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGeTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGeTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..532d087309 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGeTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class AlwaysGeTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGeTtextText"; + + AlwaysGeTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..223bf4e6e0 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class AlwaysGtTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGtTextTtext"; + + AlwaysGtTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysGtTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysGtTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..e66c6ecbe4 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysGtTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class AlwaysGtTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysGtTtextText"; + + AlwaysGtTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..df76e16f74 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class AlwaysLeTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLeTextTtext"; + + AlwaysLeTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLeTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLeTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..57dc16fb76 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLeTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class AlwaysLeTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLeTtextText"; + + AlwaysLeTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..2378a5f910 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class AlwaysLtTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLtTextTtext"; + + AlwaysLtTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysLtTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysLtTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..7a7fb42d99 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysLtTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class AlwaysLtTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysLtTtextText"; + + AlwaysLtTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..2369e43e97 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class AlwaysNeTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTextTtext"; + + AlwaysNeTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..8ed92a09ab --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class AlwaysNeTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTtextText"; + + AlwaysNeTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..f473cb3336 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class EverEqTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTextTtext"; + + EverEqTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..dbdcf2a10d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class EverEqTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTtextText"; + + EverEqTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGeTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..0f53d4231a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGeTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class EverGeTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGeTextTtext"; + + EverGeTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGeTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGeTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..6594911fef --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGeTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class EverGeTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGeTtextText"; + + EverGeTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGtTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..4710eee212 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGtTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class EverGtTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGtTextTtext"; + + EverGtTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverGtTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverGtTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..c44ef057f7 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverGtTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class EverGtTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverGtTtextText"; + + EverGtTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLeTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..4a1757c7be --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLeTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class EverLeTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLeTextTtext"; + + EverLeTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLeTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLeTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..9985d77c71 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLeTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class EverLeTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLeTtextText"; + + EverLeTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLtTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..b86921dc37 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLtTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class EverLtTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLtTextTtext"; + + EverLtTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverLtTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverLtTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..56d4d00c4b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverLtTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class EverLtTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverLtTtextText"; + + EverLtTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..c6aec3694b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class EverNeTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTextTtext"; + + EverNeTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..243a080cb7 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class EverNeTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTtextText"; + + EverNeTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TeqTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TeqTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..6d5387c671 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TeqTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class TeqTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TeqTextTtext"; + + TeqTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TeqTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TeqTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..123ba5ed3e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TeqTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class TeqTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TeqTtextText"; + + TeqTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TneTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TneTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..493e5126e4 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TneTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class TneTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TneTextTtext"; + + TneTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TneTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TneTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..bf9813b0e3 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TneTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class TneTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TneTtextText"; + + TneTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..7e21a4fe38 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +AlwaysEqTextTtextLogicalFunction::AlwaysEqTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType AlwaysEqTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector AlwaysEqTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "AlwaysEqTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view AlwaysEqTextTtextLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string AlwaysEqTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("AlwaysEqTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction AlwaysEqTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "AlwaysEqTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction AlwaysEqTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqTextTtext expects 3 params, got {}", arguments.children.size()); + return AlwaysEqTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..fa16a2e415 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +AlwaysEqTtextTextLogicalFunction::AlwaysEqTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType AlwaysEqTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector AlwaysEqTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "AlwaysEqTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view AlwaysEqTtextTextLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string AlwaysEqTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("AlwaysEqTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction AlwaysEqTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "AlwaysEqTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction AlwaysEqTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqTtextText expects 3 params, got {}", arguments.children.size()); + return AlwaysEqTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..78396dd1f5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +AlwaysGeTextTtextLogicalFunction::AlwaysGeTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType AlwaysGeTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGeTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector AlwaysGeTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGeTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "AlwaysGeTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view AlwaysGeTextTtextLogicalFunction::getType() const { return NAME; } + +bool AlwaysGeTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string AlwaysGeTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("AlwaysGeTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction AlwaysGeTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "AlwaysGeTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction AlwaysGeTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "AlwaysGeTextTtext expects 3 params, got {}", arguments.children.size()); + return AlwaysGeTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGeTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGeTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..de309a500a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGeTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +AlwaysGeTtextTextLogicalFunction::AlwaysGeTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType AlwaysGeTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGeTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector AlwaysGeTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGeTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "AlwaysGeTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view AlwaysGeTtextTextLogicalFunction::getType() const { return NAME; } + +bool AlwaysGeTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string AlwaysGeTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("AlwaysGeTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction AlwaysGeTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "AlwaysGeTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction AlwaysGeTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterAlwaysGeTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "AlwaysGeTtextText expects 3 params, got {}", arguments.children.size()); + return AlwaysGeTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..0cfebc7906 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +AlwaysGtTextTtextLogicalFunction::AlwaysGtTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType AlwaysGtTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGtTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector AlwaysGtTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGtTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "AlwaysGtTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view AlwaysGtTextTtextLogicalFunction::getType() const { return NAME; } + +bool AlwaysGtTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string AlwaysGtTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("AlwaysGtTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction AlwaysGtTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "AlwaysGtTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction AlwaysGtTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "AlwaysGtTextTtext expects 3 params, got {}", arguments.children.size()); + return AlwaysGtTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysGtTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysGtTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..2bc4c83e01 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysGtTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +AlwaysGtTtextTextLogicalFunction::AlwaysGtTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType AlwaysGtTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysGtTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector AlwaysGtTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysGtTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "AlwaysGtTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view AlwaysGtTtextTextLogicalFunction::getType() const { return NAME; } + +bool AlwaysGtTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string AlwaysGtTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("AlwaysGtTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction AlwaysGtTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "AlwaysGtTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction AlwaysGtTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterAlwaysGtTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "AlwaysGtTtextText expects 3 params, got {}", arguments.children.size()); + return AlwaysGtTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..524c676048 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +AlwaysLeTextTtextLogicalFunction::AlwaysLeTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType AlwaysLeTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLeTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector AlwaysLeTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLeTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "AlwaysLeTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view AlwaysLeTextTtextLogicalFunction::getType() const { return NAME; } + +bool AlwaysLeTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string AlwaysLeTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("AlwaysLeTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction AlwaysLeTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "AlwaysLeTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction AlwaysLeTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "AlwaysLeTextTtext expects 3 params, got {}", arguments.children.size()); + return AlwaysLeTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLeTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLeTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..d2abaf2721 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLeTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +AlwaysLeTtextTextLogicalFunction::AlwaysLeTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType AlwaysLeTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLeTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector AlwaysLeTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLeTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "AlwaysLeTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view AlwaysLeTtextTextLogicalFunction::getType() const { return NAME; } + +bool AlwaysLeTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string AlwaysLeTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("AlwaysLeTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction AlwaysLeTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "AlwaysLeTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction AlwaysLeTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterAlwaysLeTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "AlwaysLeTtextText expects 3 params, got {}", arguments.children.size()); + return AlwaysLeTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..edf0739950 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +AlwaysLtTextTtextLogicalFunction::AlwaysLtTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType AlwaysLtTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLtTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector AlwaysLtTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLtTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "AlwaysLtTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view AlwaysLtTextTtextLogicalFunction::getType() const { return NAME; } + +bool AlwaysLtTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string AlwaysLtTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("AlwaysLtTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction AlwaysLtTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "AlwaysLtTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction AlwaysLtTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "AlwaysLtTextTtext expects 3 params, got {}", arguments.children.size()); + return AlwaysLtTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysLtTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysLtTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..d9b3e39e33 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysLtTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +AlwaysLtTtextTextLogicalFunction::AlwaysLtTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType AlwaysLtTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysLtTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector AlwaysLtTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysLtTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "AlwaysLtTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view AlwaysLtTtextTextLogicalFunction::getType() const { return NAME; } + +bool AlwaysLtTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string AlwaysLtTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("AlwaysLtTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction AlwaysLtTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "AlwaysLtTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction AlwaysLtTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterAlwaysLtTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "AlwaysLtTtextText expects 3 params, got {}", arguments.children.size()); + return AlwaysLtTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..ae8f1344c2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +AlwaysNeTextTtextLogicalFunction::AlwaysNeTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType AlwaysNeTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector AlwaysNeTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "AlwaysNeTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view AlwaysNeTextTtextLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string AlwaysNeTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("AlwaysNeTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction AlwaysNeTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "AlwaysNeTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction AlwaysNeTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeTextTtext expects 3 params, got {}", arguments.children.size()); + return AlwaysNeTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..70c93952c5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +AlwaysNeTtextTextLogicalFunction::AlwaysNeTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType AlwaysNeTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector AlwaysNeTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "AlwaysNeTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view AlwaysNeTtextTextLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string AlwaysNeTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("AlwaysNeTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction AlwaysNeTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "AlwaysNeTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction AlwaysNeTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeTtextText expects 3 params, got {}", arguments.children.size()); + return AlwaysNeTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 0f5902cc58..1791eb41ff 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -246,3 +246,31 @@ add_plugin(TltTintInt LogicalFunction nes-logical-operators TltTintIntLogicalFun add_plugin(TltIntTint LogicalFunction nes-logical-operators TltIntTintLogicalFunction.cpp) add_plugin(TltTemporalTemporal LogicalFunction nes-logical-operators TltTemporalTemporalLogicalFunction.cpp) add_plugin(TboolToTint LogicalFunction nes-logical-operators TboolToTintLogicalFunction.cpp) +add_plugin(EverEqTtextText LogicalFunction nes-logical-operators EverEqTtextTextLogicalFunction.cpp) +add_plugin(EverNeTtextText LogicalFunction nes-logical-operators EverNeTtextTextLogicalFunction.cpp) +add_plugin(EverGeTtextText LogicalFunction nes-logical-operators EverGeTtextTextLogicalFunction.cpp) +add_plugin(EverGtTtextText LogicalFunction nes-logical-operators EverGtTtextTextLogicalFunction.cpp) +add_plugin(EverLeTtextText LogicalFunction nes-logical-operators EverLeTtextTextLogicalFunction.cpp) +add_plugin(EverLtTtextText LogicalFunction nes-logical-operators EverLtTtextTextLogicalFunction.cpp) +add_plugin(EverEqTextTtext LogicalFunction nes-logical-operators EverEqTextTtextLogicalFunction.cpp) +add_plugin(EverNeTextTtext LogicalFunction nes-logical-operators EverNeTextTtextLogicalFunction.cpp) +add_plugin(EverGeTextTtext LogicalFunction nes-logical-operators EverGeTextTtextLogicalFunction.cpp) +add_plugin(EverGtTextTtext LogicalFunction nes-logical-operators EverGtTextTtextLogicalFunction.cpp) +add_plugin(EverLeTextTtext LogicalFunction nes-logical-operators EverLeTextTtextLogicalFunction.cpp) +add_plugin(EverLtTextTtext LogicalFunction nes-logical-operators EverLtTextTtextLogicalFunction.cpp) +add_plugin(AlwaysEqTtextText LogicalFunction nes-logical-operators AlwaysEqTtextTextLogicalFunction.cpp) +add_plugin(AlwaysNeTtextText LogicalFunction nes-logical-operators AlwaysNeTtextTextLogicalFunction.cpp) +add_plugin(AlwaysGeTtextText LogicalFunction nes-logical-operators AlwaysGeTtextTextLogicalFunction.cpp) +add_plugin(AlwaysGtTtextText LogicalFunction nes-logical-operators AlwaysGtTtextTextLogicalFunction.cpp) +add_plugin(AlwaysLeTtextText LogicalFunction nes-logical-operators AlwaysLeTtextTextLogicalFunction.cpp) +add_plugin(AlwaysLtTtextText LogicalFunction nes-logical-operators AlwaysLtTtextTextLogicalFunction.cpp) +add_plugin(AlwaysEqTextTtext LogicalFunction nes-logical-operators AlwaysEqTextTtextLogicalFunction.cpp) +add_plugin(AlwaysNeTextTtext LogicalFunction nes-logical-operators AlwaysNeTextTtextLogicalFunction.cpp) +add_plugin(AlwaysGeTextTtext LogicalFunction nes-logical-operators AlwaysGeTextTtextLogicalFunction.cpp) +add_plugin(AlwaysGtTextTtext LogicalFunction nes-logical-operators AlwaysGtTextTtextLogicalFunction.cpp) +add_plugin(AlwaysLeTextTtext LogicalFunction nes-logical-operators AlwaysLeTextTtextLogicalFunction.cpp) +add_plugin(AlwaysLtTextTtext LogicalFunction nes-logical-operators AlwaysLtTextTtextLogicalFunction.cpp) +add_plugin(TeqTtextText LogicalFunction nes-logical-operators TeqTtextTextLogicalFunction.cpp) +add_plugin(TneTtextText LogicalFunction nes-logical-operators TneTtextTextLogicalFunction.cpp) +add_plugin(TeqTextTtext LogicalFunction nes-logical-operators TeqTextTtextLogicalFunction.cpp) +add_plugin(TneTextTtext LogicalFunction nes-logical-operators TneTextTtextLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..904e7ebf6b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +EverEqTextTtextLogicalFunction::EverEqTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType EverEqTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector EverEqTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "EverEqTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view EverEqTextTtextLogicalFunction::getType() const { return NAME; } + +bool EverEqTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string EverEqTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("EverEqTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction EverEqTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "EverEqTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction EverEqTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterEverEqTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "EverEqTextTtext expects 3 params, got {}", arguments.children.size()); + return EverEqTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..ab4ee6ed85 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +EverEqTtextTextLogicalFunction::EverEqTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType EverEqTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector EverEqTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "EverEqTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view EverEqTtextTextLogicalFunction::getType() const { return NAME; } + +bool EverEqTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string EverEqTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("EverEqTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction EverEqTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "EverEqTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction EverEqTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterEverEqTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "EverEqTtextText expects 3 params, got {}", arguments.children.size()); + return EverEqTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..32514633a9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGeTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +EverGeTextTtextLogicalFunction::EverGeTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType EverGeTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGeTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector EverGeTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGeTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "EverGeTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view EverGeTextTtextLogicalFunction::getType() const { return NAME; } + +bool EverGeTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string EverGeTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("EverGeTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction EverGeTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "EverGeTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction EverGeTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterEverGeTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "EverGeTextTtext expects 3 params, got {}", arguments.children.size()); + return EverGeTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGeTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGeTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..9e8108115b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGeTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +EverGeTtextTextLogicalFunction::EverGeTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType EverGeTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGeTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector EverGeTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGeTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "EverGeTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view EverGeTtextTextLogicalFunction::getType() const { return NAME; } + +bool EverGeTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string EverGeTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("EverGeTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction EverGeTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "EverGeTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction EverGeTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterEverGeTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "EverGeTtextText expects 3 params, got {}", arguments.children.size()); + return EverGeTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..8c77893390 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGtTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +EverGtTextTtextLogicalFunction::EverGtTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType EverGtTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGtTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector EverGtTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGtTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "EverGtTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view EverGtTextTtextLogicalFunction::getType() const { return NAME; } + +bool EverGtTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string EverGtTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("EverGtTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction EverGtTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "EverGtTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction EverGtTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterEverGtTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "EverGtTextTtext expects 3 params, got {}", arguments.children.size()); + return EverGtTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverGtTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverGtTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..d5c5d49221 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverGtTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +EverGtTtextTextLogicalFunction::EverGtTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType EverGtTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverGtTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector EverGtTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverGtTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "EverGtTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view EverGtTtextTextLogicalFunction::getType() const { return NAME; } + +bool EverGtTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string EverGtTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("EverGtTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction EverGtTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "EverGtTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction EverGtTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterEverGtTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "EverGtTtextText expects 3 params, got {}", arguments.children.size()); + return EverGtTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..7faac4fac6 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLeTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +EverLeTextTtextLogicalFunction::EverLeTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType EverLeTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLeTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector EverLeTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLeTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "EverLeTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view EverLeTextTtextLogicalFunction::getType() const { return NAME; } + +bool EverLeTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string EverLeTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("EverLeTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction EverLeTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "EverLeTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction EverLeTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterEverLeTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "EverLeTextTtext expects 3 params, got {}", arguments.children.size()); + return EverLeTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLeTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLeTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..b95fde42b0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLeTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +EverLeTtextTextLogicalFunction::EverLeTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType EverLeTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLeTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector EverLeTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLeTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "EverLeTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view EverLeTtextTextLogicalFunction::getType() const { return NAME; } + +bool EverLeTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string EverLeTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("EverLeTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction EverLeTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "EverLeTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction EverLeTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterEverLeTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "EverLeTtextText expects 3 params, got {}", arguments.children.size()); + return EverLeTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..0b0e26d872 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLtTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +EverLtTextTtextLogicalFunction::EverLtTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType EverLtTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLtTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector EverLtTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLtTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "EverLtTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view EverLtTextTtextLogicalFunction::getType() const { return NAME; } + +bool EverLtTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string EverLtTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("EverLtTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction EverLtTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "EverLtTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction EverLtTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterEverLtTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "EverLtTextTtext expects 3 params, got {}", arguments.children.size()); + return EverLtTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverLtTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverLtTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..2164cb10f1 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverLtTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +EverLtTtextTextLogicalFunction::EverLtTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType EverLtTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverLtTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector EverLtTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverLtTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "EverLtTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view EverLtTtextTextLogicalFunction::getType() const { return NAME; } + +bool EverLtTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string EverLtTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("EverLtTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction EverLtTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "EverLtTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction EverLtTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterEverLtTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "EverLtTtextText expects 3 params, got {}", arguments.children.size()); + return EverLtTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..99558ef377 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +EverNeTextTtextLogicalFunction::EverNeTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType EverNeTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector EverNeTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "EverNeTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view EverNeTextTtextLogicalFunction::getType() const { return NAME; } + +bool EverNeTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string EverNeTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("EverNeTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction EverNeTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "EverNeTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction EverNeTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterEverNeTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "EverNeTextTtext expects 3 params, got {}", arguments.children.size()); + return EverNeTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..b0b5c15c44 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +EverNeTtextTextLogicalFunction::EverNeTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType EverNeTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector EverNeTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "EverNeTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view EverNeTtextTextLogicalFunction::getType() const { return NAME; } + +bool EverNeTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string EverNeTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("EverNeTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction EverNeTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "EverNeTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction EverNeTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterEverNeTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "EverNeTtextText expects 3 params, got {}", arguments.children.size()); + return EverNeTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TeqTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TeqTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..8af4dab43a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TeqTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +TeqTextTtextLogicalFunction::TeqTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType TeqTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TeqTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector TeqTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TeqTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "TeqTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view TeqTextTtextLogicalFunction::getType() const { return NAME; } + +bool TeqTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string TeqTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("TeqTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction TeqTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "TeqTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction TeqTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterTeqTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "TeqTextTtext expects 3 params, got {}", arguments.children.size()); + return TeqTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TeqTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TeqTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..3b4889b29c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TeqTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +TeqTtextTextLogicalFunction::TeqTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType TeqTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TeqTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector TeqTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TeqTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "TeqTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view TeqTtextTextLogicalFunction::getType() const { return NAME; } + +bool TeqTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string TeqTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("TeqTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction TeqTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "TeqTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction TeqTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterTeqTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "TeqTtextText expects 3 params, got {}", arguments.children.size()); + return TeqTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TneTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TneTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..544b93b5ee --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TneTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +TneTextTtextLogicalFunction::TneTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType TneTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TneTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector TneTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TneTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "TneTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view TneTextTtextLogicalFunction::getType() const { return NAME; } + +bool TneTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string TneTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("TneTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction TneTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "TneTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction TneTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterTneTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "TneTextTtext expects 3 params, got {}", arguments.children.size()); + return TneTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TneTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TneTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..7eacd1ff1a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TneTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +TneTtextTextLogicalFunction::TneTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType TneTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TneTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector TneTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TneTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "TneTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view TneTtextTextLogicalFunction::getType() const { return NAME; } + +bool TneTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string TneTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("TneTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction TneTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "TneTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction TneTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterTneTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "TneTtextText expects 3 params, got {}", arguments.children.size()); + return TneTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..c153240e8c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..bb18e0e23b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..af0e9f151f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysGeTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGeTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGeTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGeTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..532634173a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGeTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysGeTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGeTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..bfd56b4d06 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysGtTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGtTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysGtTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysGtTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..0eefe82b23 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysGtTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysGtTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysGtTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..8926066803 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysLeTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLeTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLeTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLeTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..0458033afd --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLeTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysLeTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLeTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..d4f63548ce --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysLtTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLtTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysLtTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysLtTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..9c3f5862d3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysLtTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysLtTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysLtTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..30bb284e6d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..22d74b1704 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..219398d2d4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..28c8346c06 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGeTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..c033017647 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGeTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverGeTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGeTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGeTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGeTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..e75180efa1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGeTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverGeTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGeTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGtTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..9b919651de --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGtTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverGtTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGtTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverGtTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverGtTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..e9cb4b2425 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverGtTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverGtTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + EverGtTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLeTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..5b13de2733 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLeTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverLeTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLeTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLeTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLeTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..9b40274844 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLeTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverLeTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLeTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLtTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..ff1d4e1de3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLtTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverLtTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLtTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverLtTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverLtTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..d3f18c8fd8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverLtTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverLtTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + EverLtTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..43f3c09e8e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..729ae700a2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TeqTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TeqTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..0493ddbfe0 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TeqTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TeqTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + TeqTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TeqTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TeqTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..61ae8ba132 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TeqTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TeqTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + TeqTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TneTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TneTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..ec18b8bbd9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TneTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TneTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + TneTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TneTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TneTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..99e46706ba --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TneTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TneTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + TneTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..1d0db7a137 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTextTtextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +AlwaysEqTextTtextPhysicalFunction::AlwaysEqTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = always_eq_text_ttext(txt, temp); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..93bdd51e9e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTtextTextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +AlwaysEqTtextTextPhysicalFunction::AlwaysEqTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal AlwaysEqTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = always_eq_ttext_text(temp, txt); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..955a72eb30 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeTextTtextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +AlwaysGeTextTtextPhysicalFunction::AlwaysGeTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGeTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = always_ge_text_ttext(txt, temp); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGeTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGeTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysGeTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGeTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGeTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..403605380d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGeTtextTextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +AlwaysGeTtextTextPhysicalFunction::AlwaysGeTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGeTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = always_ge_ttext_text(temp, txt); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGeTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGeTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysGeTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..e2627e708b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtTextTtextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +AlwaysGtTextTtextPhysicalFunction::AlwaysGtTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGtTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = always_gt_text_ttext(txt, temp); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGtTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGtTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysGtTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysGtTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysGtTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..e2743d07c7 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysGtTtextTextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +AlwaysGtTtextTextPhysicalFunction::AlwaysGtTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal AlwaysGtTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = always_gt_ttext_text(temp, txt); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysGtTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysGtTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysGtTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..0e5a9d1aee --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeTextTtextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +AlwaysLeTextTtextPhysicalFunction::AlwaysLeTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLeTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = always_le_text_ttext(txt, temp); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLeTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLeTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysLeTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLeTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLeTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..1b17b2c5a1 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLeTtextTextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +AlwaysLeTtextTextPhysicalFunction::AlwaysLeTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLeTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = always_le_ttext_text(temp, txt); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLeTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLeTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysLeTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..ca73bb826e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtTextTtextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +AlwaysLtTextTtextPhysicalFunction::AlwaysLtTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLtTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = always_lt_text_ttext(txt, temp); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLtTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLtTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysLtTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysLtTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysLtTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..eae1a0dc44 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysLtTtextTextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +AlwaysLtTtextTextPhysicalFunction::AlwaysLtTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal AlwaysLtTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = always_lt_ttext_text(temp, txt); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysLtTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysLtTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysLtTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..83e39a5bfa --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTextTtextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +AlwaysNeTextTtextPhysicalFunction::AlwaysNeTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = always_ne_text_ttext(txt, temp); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..d962d3476a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTtextTextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +AlwaysNeTtextTextPhysicalFunction::AlwaysNeTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal AlwaysNeTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = always_ne_ttext_text(temp, txt); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 5224235981..7a1ba07400 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -245,4 +245,32 @@ add_plugin(TltTintInt PhysicalFunction nes-physical-operators TltTintIntPhysical add_plugin(TltIntTint PhysicalFunction nes-physical-operators TltIntTintPhysicalFunction.cpp) add_plugin(TltTemporalTemporal PhysicalFunction nes-physical-operators TltTemporalTemporalPhysicalFunction.cpp) add_plugin(TboolToTint PhysicalFunction nes-physical-operators TboolToTintPhysicalFunction.cpp) +add_plugin(EverEqTtextText PhysicalFunction nes-physical-operators EverEqTtextTextPhysicalFunction.cpp) +add_plugin(EverNeTtextText PhysicalFunction nes-physical-operators EverNeTtextTextPhysicalFunction.cpp) +add_plugin(EverGeTtextText PhysicalFunction nes-physical-operators EverGeTtextTextPhysicalFunction.cpp) +add_plugin(EverGtTtextText PhysicalFunction nes-physical-operators EverGtTtextTextPhysicalFunction.cpp) +add_plugin(EverLeTtextText PhysicalFunction nes-physical-operators EverLeTtextTextPhysicalFunction.cpp) +add_plugin(EverLtTtextText PhysicalFunction nes-physical-operators EverLtTtextTextPhysicalFunction.cpp) +add_plugin(EverEqTextTtext PhysicalFunction nes-physical-operators EverEqTextTtextPhysicalFunction.cpp) +add_plugin(EverNeTextTtext PhysicalFunction nes-physical-operators EverNeTextTtextPhysicalFunction.cpp) +add_plugin(EverGeTextTtext PhysicalFunction nes-physical-operators EverGeTextTtextPhysicalFunction.cpp) +add_plugin(EverGtTextTtext PhysicalFunction nes-physical-operators EverGtTextTtextPhysicalFunction.cpp) +add_plugin(EverLeTextTtext PhysicalFunction nes-physical-operators EverLeTextTtextPhysicalFunction.cpp) +add_plugin(EverLtTextTtext PhysicalFunction nes-physical-operators EverLtTextTtextPhysicalFunction.cpp) +add_plugin(AlwaysEqTtextText PhysicalFunction nes-physical-operators AlwaysEqTtextTextPhysicalFunction.cpp) +add_plugin(AlwaysNeTtextText PhysicalFunction nes-physical-operators AlwaysNeTtextTextPhysicalFunction.cpp) +add_plugin(AlwaysGeTtextText PhysicalFunction nes-physical-operators AlwaysGeTtextTextPhysicalFunction.cpp) +add_plugin(AlwaysGtTtextText PhysicalFunction nes-physical-operators AlwaysGtTtextTextPhysicalFunction.cpp) +add_plugin(AlwaysLeTtextText PhysicalFunction nes-physical-operators AlwaysLeTtextTextPhysicalFunction.cpp) +add_plugin(AlwaysLtTtextText PhysicalFunction nes-physical-operators AlwaysLtTtextTextPhysicalFunction.cpp) +add_plugin(AlwaysEqTextTtext PhysicalFunction nes-physical-operators AlwaysEqTextTtextPhysicalFunction.cpp) +add_plugin(AlwaysNeTextTtext PhysicalFunction nes-physical-operators AlwaysNeTextTtextPhysicalFunction.cpp) +add_plugin(AlwaysGeTextTtext PhysicalFunction nes-physical-operators AlwaysGeTextTtextPhysicalFunction.cpp) +add_plugin(AlwaysGtTextTtext PhysicalFunction nes-physical-operators AlwaysGtTextTtextPhysicalFunction.cpp) +add_plugin(AlwaysLeTextTtext PhysicalFunction nes-physical-operators AlwaysLeTextTtextPhysicalFunction.cpp) +add_plugin(AlwaysLtTextTtext PhysicalFunction nes-physical-operators AlwaysLtTextTtextPhysicalFunction.cpp) +add_plugin(TeqTtextText PhysicalFunction nes-physical-operators TeqTtextTextPhysicalFunction.cpp) +add_plugin(TneTtextText PhysicalFunction nes-physical-operators TneTtextTextPhysicalFunction.cpp) +add_plugin(TeqTextTtext PhysicalFunction nes-physical-operators TeqTextTtextPhysicalFunction.cpp) +add_plugin(TneTextTtext PhysicalFunction nes-physical-operators TneTextTtextPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..b220c17db5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTextTtextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +EverEqTextTtextPhysicalFunction::EverEqTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal EverEqTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = ever_eq_text_ttext(txt, temp); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverEqTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..6e40e212b4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTtextTextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +EverEqTtextTextPhysicalFunction::EverEqTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal EverEqTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = ever_eq_ttext_text(temp, txt); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverEqTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGeTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..492b064d6b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGeTextTtextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +EverGeTextTtextPhysicalFunction::EverGeTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal EverGeTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = ever_ge_text_ttext(txt, temp); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGeTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGeTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverGeTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGeTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGeTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..1205e71ec5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGeTtextTextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +EverGeTtextTextPhysicalFunction::EverGeTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal EverGeTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = ever_ge_ttext_text(temp, txt); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGeTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGeTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverGeTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGtTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..a2cdb95ab0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGtTextTtextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +EverGtTextTtextPhysicalFunction::EverGtTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal EverGtTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = ever_gt_text_ttext(txt, temp); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGtTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGtTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverGtTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverGtTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverGtTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..8840ab0cad --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverGtTtextTextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +EverGtTtextTextPhysicalFunction::EverGtTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal EverGtTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = ever_gt_ttext_text(temp, txt); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverGtTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverGtTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverGtTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLeTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..b813d4dc2c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLeTextTtextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +EverLeTextTtextPhysicalFunction::EverLeTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal EverLeTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = ever_le_text_ttext(txt, temp); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLeTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLeTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverLeTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLeTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLeTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..9e5b4da4b4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLeTtextTextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +EverLeTtextTextPhysicalFunction::EverLeTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal EverLeTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = ever_le_ttext_text(temp, txt); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLeTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLeTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverLeTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLtTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..2d712dac08 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLtTextTtextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +EverLtTextTtextPhysicalFunction::EverLtTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal EverLtTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = ever_lt_text_ttext(txt, temp); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLtTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLtTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverLtTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverLtTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverLtTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..925aef9102 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverLtTtextTextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +EverLtTtextTextPhysicalFunction::EverLtTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal EverLtTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = ever_lt_ttext_text(temp, txt); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverLtTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverLtTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverLtTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..d1da80d397 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTextTtextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +EverNeTextTtextPhysicalFunction::EverNeTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal EverNeTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = ever_ne_text_ttext(txt, temp); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverNeTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..2b3d082952 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTtextTextPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +EverNeTtextTextPhysicalFunction::EverNeTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal EverNeTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + int result = ever_ne_ttext_text(temp, txt); + free(temp); + free(txt); + return static_cast(result); + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverNeTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TeqTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TeqTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..35fc159b03 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TeqTextTtextPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TeqTextTtextPhysicalFunction::TeqTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TeqTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + Temporal* res = teq_text_ttext(txt, temp); + free(temp); + free(txt); + if (!res) return 0.0; + bool v2 = tbool_start_value(res); + free(res); + return v2 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTeqTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TeqTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TeqTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TeqTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TeqTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..4f280736cb --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TeqTtextTextPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TeqTtextTextPhysicalFunction::TeqTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TeqTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + Temporal* res = teq_ttext_text(temp, txt); + free(temp); + free(txt); + if (!res) return 0.0; + bool v2 = tbool_start_value(res); + free(res); + return v2 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTeqTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TeqTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TeqTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TneTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TneTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..06f16c4156 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TneTextTtextPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TneTextTtextPhysicalFunction::TneTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TneTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + Temporal* res = tne_text_ttext(txt, temp); + free(temp); + free(txt); + if (!res) return 0.0; + bool v2 = tbool_start_value(res); + free(res); + return v2 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTneTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TneTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TneTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TneTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TneTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..7fdb6e675d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TneTtextTextPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TneTtextTextPhysicalFunction::TneTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TneTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + Temporal* res = tne_ttext_text(temp, txt); + free(temp); + free(txt); + if (!res) return 0.0; + bool v2 = tbool_start_value(res); + free(res); + return v2 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTneTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TneTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TneTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index ce613ef640..72d4d77edb 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT; sinkClause: INTO sink (',' sink)*; @@ -716,6 +716,34 @@ TLT_TINT_INT: 'TLT_TINT_INT' | 'tlt_tint_int'; TLT_INT_TINT: 'TLT_INT_TINT' | 'tlt_int_tint'; TLT_TEMPORAL_TEMPORAL: 'TLT_TEMPORAL_TEMPORAL' | 'tlt_temporal_temporal'; TBOOL_TO_TINT: 'TBOOL_TO_TINT' | 'tbool_to_tint'; +EVER_EQ_TTEXT_TEXT: 'EVER_EQ_TTEXT_TEXT' | 'ever_eq_ttext_text'; +EVER_NE_TTEXT_TEXT: 'EVER_NE_TTEXT_TEXT' | 'ever_ne_ttext_text'; +EVER_GE_TTEXT_TEXT: 'EVER_GE_TTEXT_TEXT' | 'ever_ge_ttext_text'; +EVER_GT_TTEXT_TEXT: 'EVER_GT_TTEXT_TEXT' | 'ever_gt_ttext_text'; +EVER_LE_TTEXT_TEXT: 'EVER_LE_TTEXT_TEXT' | 'ever_le_ttext_text'; +EVER_LT_TTEXT_TEXT: 'EVER_LT_TTEXT_TEXT' | 'ever_lt_ttext_text'; +EVER_EQ_TEXT_TTEXT: 'EVER_EQ_TEXT_TTEXT' | 'ever_eq_text_ttext'; +EVER_NE_TEXT_TTEXT: 'EVER_NE_TEXT_TTEXT' | 'ever_ne_text_ttext'; +EVER_GE_TEXT_TTEXT: 'EVER_GE_TEXT_TTEXT' | 'ever_ge_text_ttext'; +EVER_GT_TEXT_TTEXT: 'EVER_GT_TEXT_TTEXT' | 'ever_gt_text_ttext'; +EVER_LE_TEXT_TTEXT: 'EVER_LE_TEXT_TTEXT' | 'ever_le_text_ttext'; +EVER_LT_TEXT_TTEXT: 'EVER_LT_TEXT_TTEXT' | 'ever_lt_text_ttext'; +ALWAYS_EQ_TTEXT_TEXT: 'ALWAYS_EQ_TTEXT_TEXT' | 'always_eq_ttext_text'; +ALWAYS_NE_TTEXT_TEXT: 'ALWAYS_NE_TTEXT_TEXT' | 'always_ne_ttext_text'; +ALWAYS_GE_TTEXT_TEXT: 'ALWAYS_GE_TTEXT_TEXT' | 'always_ge_ttext_text'; +ALWAYS_GT_TTEXT_TEXT: 'ALWAYS_GT_TTEXT_TEXT' | 'always_gt_ttext_text'; +ALWAYS_LE_TTEXT_TEXT: 'ALWAYS_LE_TTEXT_TEXT' | 'always_le_ttext_text'; +ALWAYS_LT_TTEXT_TEXT: 'ALWAYS_LT_TTEXT_TEXT' | 'always_lt_ttext_text'; +ALWAYS_EQ_TEXT_TTEXT: 'ALWAYS_EQ_TEXT_TTEXT' | 'always_eq_text_ttext'; +ALWAYS_NE_TEXT_TTEXT: 'ALWAYS_NE_TEXT_TTEXT' | 'always_ne_text_ttext'; +ALWAYS_GE_TEXT_TTEXT: 'ALWAYS_GE_TEXT_TTEXT' | 'always_ge_text_ttext'; +ALWAYS_GT_TEXT_TTEXT: 'ALWAYS_GT_TEXT_TTEXT' | 'always_gt_text_ttext'; +ALWAYS_LE_TEXT_TTEXT: 'ALWAYS_LE_TEXT_TTEXT' | 'always_le_text_ttext'; +ALWAYS_LT_TEXT_TTEXT: 'ALWAYS_LT_TEXT_TTEXT' | 'always_lt_text_ttext'; +TEQ_TTEXT_TEXT: 'TEQ_TTEXT_TEXT' | 'teq_ttext_text'; +TNE_TTEXT_TEXT: 'TNE_TTEXT_TEXT' | 'tne_ttext_text'; +TEQ_TEXT_TTEXT: 'TEQ_TEXT_TTEXT' | 'teq_text_ttext'; +TNE_TEXT_TTEXT: 'TNE_TEXT_TTEXT' | 'tne_text_ttext'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index fc61ea38d2..7a0a6c461b 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -297,6 +297,34 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -7602,6 +7630,818 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TBOOL_TO_TINT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TTEXT_TEXT */ + case AntlrSQLLexer::EVER_EQ_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_TTEXT_TEXT */ + case AntlrSQLLexer::EVER_NE_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_NE_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GE_TTEXT_TEXT */ + case AntlrSQLLexer::EVER_GE_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GE_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGeTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GE_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GT_TTEXT_TEXT */ + case AntlrSQLLexer::EVER_GT_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GT_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGtTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GT_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LE_TTEXT_TEXT */ + case AntlrSQLLexer::EVER_LE_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LE_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLeTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LE_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LT_TTEXT_TEXT */ + case AntlrSQLLexer::EVER_LT_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LT_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLtTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LT_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_EQ_TEXT_TTEXT */ + case AntlrSQLLexer::EVER_EQ_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_EQ_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverEqTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_EQ_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_NE_TEXT_TTEXT */ + case AntlrSQLLexer::EVER_NE_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_NE_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverNeTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_NE_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GE_TEXT_TTEXT */ + case AntlrSQLLexer::EVER_GE_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GE_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGeTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GE_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_GT_TEXT_TTEXT */ + case AntlrSQLLexer::EVER_GT_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_GT_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverGtTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_GT_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LE_TEXT_TTEXT */ + case AntlrSQLLexer::EVER_LE_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LE_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLeTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LE_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: EVER_LT_TEXT_TTEXT */ + case AntlrSQLLexer::EVER_LT_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("EVER_LT_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(EverLtTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: EVER_LT_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TTEXT_TEXT */ + case AntlrSQLLexer::ALWAYS_EQ_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_TTEXT_TEXT */ + case AntlrSQLLexer::ALWAYS_NE_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_NE_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysNeTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GE_TTEXT_TEXT */ + case AntlrSQLLexer::ALWAYS_GE_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GE_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGeTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GE_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GT_TTEXT_TEXT */ + case AntlrSQLLexer::ALWAYS_GT_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GT_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGtTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GT_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LE_TTEXT_TEXT */ + case AntlrSQLLexer::ALWAYS_LE_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LE_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLeTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LE_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LT_TTEXT_TEXT */ + case AntlrSQLLexer::ALWAYS_LT_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LT_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLtTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LT_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TEXT_TTEXT */ + case AntlrSQLLexer::ALWAYS_EQ_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_EQ_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysEqTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_NE_TEXT_TTEXT */ + case AntlrSQLLexer::ALWAYS_NE_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_NE_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysNeTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GE_TEXT_TTEXT */ + case AntlrSQLLexer::ALWAYS_GE_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GE_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGeTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GE_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_GT_TEXT_TTEXT */ + case AntlrSQLLexer::ALWAYS_GT_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_GT_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysGtTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_GT_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LE_TEXT_TTEXT */ + case AntlrSQLLexer::ALWAYS_LE_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LE_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLeTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LE_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: ALWAYS_LT_TEXT_TTEXT */ + case AntlrSQLLexer::ALWAYS_LT_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("ALWAYS_LT_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(AlwaysLtTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: ALWAYS_LT_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: TEQ_TTEXT_TEXT */ + case AntlrSQLLexer::TEQ_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TEQ_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TeqTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TEQ_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: TNE_TTEXT_TEXT */ + case AntlrSQLLexer::TNE_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TNE_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TneTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TNE_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: TEQ_TEXT_TTEXT */ + case AntlrSQLLexer::TEQ_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TEQ_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TeqTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TEQ_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: TNE_TEXT_TTEXT */ + case AntlrSQLLexer::TNE_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TNE_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TneTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TNE_TEXT_TTEXT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 570d12d75cc9157c592fde967cb8ead0184021b0 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Sun, 14 Jun 2026 06:51:36 +0200 Subject: [PATCH 43/86] feat(meos): add TGE/TGT/TLE/TLT_{TTEXT_TEXT,TEXT_TTEXT} NES operators (W94) Adds 8 per-event NES scalar operators for ordered comparison between a single-instant ttext and a text literal, in both argument orders: TGE_TTEXT_TEXT, TGE_TEXT_TTEXT, TGT_TTEXT_TEXT, TGT_TEXT_TTEXT, TLE_TTEXT_TEXT, TLE_TEXT_TTEXT, TLT_TTEXT_TEXT, TLT_TEXT_TTEXT. Each operator takes (textValue:VARCHAR, textRef:VARCHAR, ts:UINT64), builds a single-instant ttext via ttext_in, converts the reference string via cstring_to_text, delegates to the corresponding MEOS tge_*/tgt_*/tle_*/tlt_* kernel (returning a single-instant tbool), extracts the boolean result via tbool_start_value, and returns FLOAT64 1.0/0.0. Wired across logical/physical CMakeLists, AntlrSQL.g4 functionName rule and lexer section, and AntlrSQLQueryPlanCreator.cpp. --- .../Meos/TgeTextTtextLogicalFunction.hpp | 43 ++++ .../Meos/TgeTtextTextLogicalFunction.hpp | 43 ++++ .../Meos/TgtTextTtextLogicalFunction.hpp | 43 ++++ .../Meos/TgtTtextTextLogicalFunction.hpp | 43 ++++ .../Meos/TleTextTtextLogicalFunction.hpp | 43 ++++ .../Meos/TleTtextTextLogicalFunction.hpp | 43 ++++ .../Meos/TltTextTtextLogicalFunction.hpp | 43 ++++ .../Meos/TltTtextTextLogicalFunction.hpp | 43 ++++ .../src/Functions/Meos/CMakeLists.txt | 8 + .../Meos/TgeTextTtextLogicalFunction.cpp | 93 +++++++ .../Meos/TgeTtextTextLogicalFunction.cpp | 93 +++++++ .../Meos/TgtTextTtextLogicalFunction.cpp | 93 +++++++ .../Meos/TgtTtextTextLogicalFunction.cpp | 93 +++++++ .../Meos/TleTextTtextLogicalFunction.cpp | 93 +++++++ .../Meos/TleTtextTextLogicalFunction.cpp | 93 +++++++ .../Meos/TltTextTtextLogicalFunction.cpp | 93 +++++++ .../Meos/TltTtextTextLogicalFunction.cpp | 93 +++++++ .../Meos/TgeTextTtextPhysicalFunction.hpp | 36 +++ .../Meos/TgeTtextTextPhysicalFunction.hpp | 36 +++ .../Meos/TgtTextTtextPhysicalFunction.hpp | 36 +++ .../Meos/TgtTtextTextPhysicalFunction.hpp | 36 +++ .../Meos/TleTextTtextPhysicalFunction.hpp | 36 +++ .../Meos/TleTtextTextPhysicalFunction.hpp | 36 +++ .../Meos/TltTextTtextPhysicalFunction.hpp | 36 +++ .../Meos/TltTtextTextPhysicalFunction.hpp | 36 +++ .../src/Functions/Meos/CMakeLists.txt | 8 + .../Meos/TgeTextTtextPhysicalFunction.cpp | 93 +++++++ .../Meos/TgeTtextTextPhysicalFunction.cpp | 93 +++++++ .../Meos/TgtTextTtextPhysicalFunction.cpp | 93 +++++++ .../Meos/TgtTtextTextPhysicalFunction.cpp | 93 +++++++ .../Meos/TleTextTtextPhysicalFunction.cpp | 93 +++++++ .../Meos/TleTtextTextPhysicalFunction.cpp | 93 +++++++ .../Meos/TltTextTtextPhysicalFunction.cpp | 93 +++++++ .../Meos/TltTtextTextPhysicalFunction.cpp | 93 +++++++ nes-sql-parser/AntlrSQL.g4 | 10 +- .../src/AntlrSQLQueryPlanCreator.cpp | 240 ++++++++++++++++++ 36 files changed, 2385 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TgeTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TgeTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TgtTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TgtTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TleTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TleTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TltTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TltTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgeTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgeTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgtTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TgtTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TleTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TleTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TltTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TltTtextTextLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgeTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgeTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgtTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TgtTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TleTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TleTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TltTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TltTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgeTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgeTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgtTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TgtTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TleTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TleTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TltTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TltTtextTextPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TgeTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgeTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..8bb1537430 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgeTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class TgeTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgeTextTtext"; + + TgeTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TgeTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgeTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..7a7930e4ae --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgeTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class TgeTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgeTtextText"; + + TgeTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TgtTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgtTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..27076a6c84 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgtTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class TgtTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgtTextTtext"; + + TgtTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TgtTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TgtTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..c060c8b492 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TgtTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class TgtTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TgtTtextText"; + + TgtTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TleTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TleTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..fcff9befd6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TleTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class TleTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TleTextTtext"; + + TleTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TleTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TleTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..e2440ecbb8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TleTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class TleTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TleTtextText"; + + TleTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TltTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TltTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..ec8e33ee68 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TltTextTtextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class TltTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TltTextTtext"; + + TltTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TltTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TltTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..bd51064f6a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TltTtextTextLogicalFunction.hpp @@ -0,0 +1,43 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once +#include +#include +#include + +namespace NES { + +class TltTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TltTtextText"; + + TltTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ref, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType&) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector&) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept&) const override; + std::string explain(ExplainVerbosity) const override; + LogicalFunction withInferredDataType(const Schema&) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 1791eb41ff..367216d983 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -274,3 +274,11 @@ add_plugin(TeqTtextText LogicalFunction nes-logical-operators TeqTtextTextLogica add_plugin(TneTtextText LogicalFunction nes-logical-operators TneTtextTextLogicalFunction.cpp) add_plugin(TeqTextTtext LogicalFunction nes-logical-operators TeqTextTtextLogicalFunction.cpp) add_plugin(TneTextTtext LogicalFunction nes-logical-operators TneTextTtextLogicalFunction.cpp) +add_plugin(TgeTtextText LogicalFunction nes-logical-operators TgeTtextTextLogicalFunction.cpp) +add_plugin(TgeTextTtext LogicalFunction nes-logical-operators TgeTextTtextLogicalFunction.cpp) +add_plugin(TgtTtextText LogicalFunction nes-logical-operators TgtTtextTextLogicalFunction.cpp) +add_plugin(TgtTextTtext LogicalFunction nes-logical-operators TgtTextTtextLogicalFunction.cpp) +add_plugin(TleTtextText LogicalFunction nes-logical-operators TleTtextTextLogicalFunction.cpp) +add_plugin(TleTextTtext LogicalFunction nes-logical-operators TleTextTtextLogicalFunction.cpp) +add_plugin(TltTtextText LogicalFunction nes-logical-operators TltTtextTextLogicalFunction.cpp) +add_plugin(TltTextTtext LogicalFunction nes-logical-operators TltTextTtextLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TgeTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgeTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..429fa56ba6 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgeTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +TgeTextTtextLogicalFunction::TgeTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType TgeTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgeTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector TgeTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgeTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "TgeTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view TgeTextTtextLogicalFunction::getType() const { return NAME; } + +bool TgeTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string TgeTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("TgeTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction TgeTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "TgeTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction TgeTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterTgeTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "TgeTextTtext expects 3 params, got {}", arguments.children.size()); + return TgeTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TgeTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgeTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..f5b37484ef --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgeTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +TgeTtextTextLogicalFunction::TgeTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType TgeTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgeTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector TgeTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgeTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "TgeTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view TgeTtextTextLogicalFunction::getType() const { return NAME; } + +bool TgeTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string TgeTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("TgeTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction TgeTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "TgeTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction TgeTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterTgeTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "TgeTtextText expects 3 params, got {}", arguments.children.size()); + return TgeTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TgtTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgtTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..1abb3ac98f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgtTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +TgtTextTtextLogicalFunction::TgtTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType TgtTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgtTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector TgtTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgtTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "TgtTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view TgtTextTtextLogicalFunction::getType() const { return NAME; } + +bool TgtTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string TgtTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("TgtTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction TgtTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "TgtTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction TgtTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterTgtTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "TgtTextTtext expects 3 params, got {}", arguments.children.size()); + return TgtTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TgtTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TgtTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..63d0082c52 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TgtTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +TgtTtextTextLogicalFunction::TgtTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType TgtTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TgtTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector TgtTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TgtTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "TgtTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view TgtTtextTextLogicalFunction::getType() const { return NAME; } + +bool TgtTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string TgtTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("TgtTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction TgtTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "TgtTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction TgtTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterTgtTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "TgtTtextText expects 3 params, got {}", arguments.children.size()); + return TgtTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TleTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TleTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..5151df6e5c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TleTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +TleTextTtextLogicalFunction::TleTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType TleTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TleTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector TleTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TleTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "TleTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view TleTextTtextLogicalFunction::getType() const { return NAME; } + +bool TleTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string TleTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("TleTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction TleTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "TleTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction TleTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterTleTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "TleTextTtext expects 3 params, got {}", arguments.children.size()); + return TleTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TleTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TleTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..cf4febc98e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TleTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +TleTtextTextLogicalFunction::TleTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType TleTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TleTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector TleTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TleTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "TleTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view TleTtextTextLogicalFunction::getType() const { return NAME; } + +bool TleTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string TleTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("TleTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction TleTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "TleTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction TleTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterTleTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "TleTtextText expects 3 params, got {}", arguments.children.size()); + return TleTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TltTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TltTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..2ae91d552a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TltTextTtextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +TltTextTtextLogicalFunction::TltTextTtextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType TltTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TltTextTtextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector TltTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TltTextTtextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "TltTextTtext expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view TltTextTtextLogicalFunction::getType() const { return NAME; } + +bool TltTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string TltTextTtextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("TltTextTtext({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction TltTextTtextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "TltTextTtext: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction TltTextTtextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterTltTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "TltTextTtext expects 3 params, got {}", arguments.children.size()); + return TltTextTtextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TltTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TltTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..24978b502e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TltTtextTextLogicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES { + +TltTtextTextLogicalFunction::TltTtextTextLogicalFunction( + LogicalFunction value, LogicalFunction ref, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) { + parameters = {std::move(value), std::move(ref), std::move(ts)}; +} + +DataType TltTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TltTtextTextLogicalFunction::withDataType(const DataType& dt) const { + auto c = *this; c.dataType = dt; return c; +} + +std::vector TltTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TltTtextTextLogicalFunction::withChildren(const std::vector& ch) const { + PRECONDITION(ch.size() == 3, "TltTtextText expects 3 params, got {}", ch.size()); + auto c = *this; c.parameters = ch; return c; +} + +std::string_view TltTtextTextLogicalFunction::getType() const { return NAME; } + +bool TltTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const { + const auto* o = dynamic_cast(&rhs); + return o && parameters == o->parameters; +} + +std::string TltTtextTextLogicalFunction::explain(ExplainVerbosity v) const { + return fmt::format("TltTtextText({}, {}, {})", + parameters[0].explain(v), parameters[1].explain(v), parameters[2].explain(v)); +} + +LogicalFunction TltTtextTextLogicalFunction::withInferredDataType(const Schema& s) const { + std::vector ch; + ch.reserve(3); + for (auto& p : parameters) ch.push_back(p.withInferredDataType(s)); + auto isStr = [](const DataType& dt) { return dt.isType(DataType::Type::VARSIZED); }; + auto isTime = [](const DataType& dt) { return dt.isType(DataType::Type::UINT64); }; + INVARIANT(isStr(ch[0].getDataType()) && isStr(ch[1].getDataType()) && isTime(ch[2].getDataType()), + "TltTtextText: expects (VARCHAR, VARCHAR, UINT64)"); + return withChildren(ch); +} + +SerializableFunction TltTtextTextLogicalFunction::serialize() const { + SerializableFunction sf; + sf.set_function_type(std::string(NAME)); + for (auto& p : parameters) *sf.add_children() = p.serialize(); + DataTypeSerializationUtil::serializeDataType(dataType, sf.mutable_data_type()); + return sf; +} + +LogicalFunctionRegistryReturnType +LogicalFunctionGeneratedRegistrar::RegisterTltTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) { + PRECONDITION(arguments.children.size() == 3, + "TltTtextText expects 3 params, got {}", arguments.children.size()); + return TltTtextTextLogicalFunction( + arguments.children[0], arguments.children[1], arguments.children[2]); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgeTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgeTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..a309a82757 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgeTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TgeTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + TgeTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgeTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgeTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..baa8635e82 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgeTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TgeTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + TgeTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgtTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgtTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..f0f7528b53 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgtTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TgtTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + TgtTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TgtTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TgtTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..5b7308bdd9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TgtTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TgtTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + TgtTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TleTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TleTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..c79541223f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TleTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TleTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + TleTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TleTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TleTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..fc2b5f13d4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TleTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TleTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + TleTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TltTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TltTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..9b69c258ef --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TltTextTtextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TltTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + TltTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TltTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TltTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..eed9e7c902 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TltTtextTextPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TltTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + TltTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction refFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 7a1ba07400..4dd15337c1 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -273,4 +273,12 @@ add_plugin(TeqTtextText PhysicalFunction nes-physical-operators TeqTtextTextPhys add_plugin(TneTtextText PhysicalFunction nes-physical-operators TneTtextTextPhysicalFunction.cpp) add_plugin(TeqTextTtext PhysicalFunction nes-physical-operators TeqTextTtextPhysicalFunction.cpp) add_plugin(TneTextTtext PhysicalFunction nes-physical-operators TneTextTtextPhysicalFunction.cpp) +add_plugin(TgeTtextText PhysicalFunction nes-physical-operators TgeTtextTextPhysicalFunction.cpp) +add_plugin(TgeTextTtext PhysicalFunction nes-physical-operators TgeTextTtextPhysicalFunction.cpp) +add_plugin(TgtTtextText PhysicalFunction nes-physical-operators TgtTtextTextPhysicalFunction.cpp) +add_plugin(TgtTextTtext PhysicalFunction nes-physical-operators TgtTextTtextPhysicalFunction.cpp) +add_plugin(TleTtextText PhysicalFunction nes-physical-operators TleTtextTextPhysicalFunction.cpp) +add_plugin(TleTextTtext PhysicalFunction nes-physical-operators TleTextTtextPhysicalFunction.cpp) +add_plugin(TltTtextText PhysicalFunction nes-physical-operators TltTtextTextPhysicalFunction.cpp) +add_plugin(TltTextTtext PhysicalFunction nes-physical-operators TltTextTtextPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TgeTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgeTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..e66a0fa702 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgeTextTtextPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TgeTextTtextPhysicalFunction::TgeTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TgeTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + Temporal* res = tge_text_ttext(txt, temp); + free(temp); + free(txt); + if (!res) return 0.0; + bool v2 = tbool_start_value(res); + free(res); + return v2 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgeTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgeTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TgeTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TgeTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgeTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..070d5b7d48 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgeTtextTextPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TgeTtextTextPhysicalFunction::TgeTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TgeTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + Temporal* res = tge_ttext_text(temp, txt); + free(temp); + free(txt); + if (!res) return 0.0; + bool v2 = tbool_start_value(res); + free(res); + return v2 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgeTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgeTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TgeTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TgtTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgtTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..e54dec18b2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgtTextTtextPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TgtTextTtextPhysicalFunction::TgtTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TgtTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + Temporal* res = tgt_text_ttext(txt, temp); + free(temp); + free(txt); + if (!res) return 0.0; + bool v2 = tbool_start_value(res); + free(res); + return v2 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgtTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgtTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TgtTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TgtTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TgtTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..2e42136d79 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TgtTtextTextPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TgtTtextTextPhysicalFunction::TgtTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TgtTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + Temporal* res = tgt_ttext_text(temp, txt); + free(temp); + free(txt); + if (!res) return 0.0; + bool v2 = tbool_start_value(res); + free(res); + return v2 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTgtTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TgtTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TgtTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TleTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TleTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..cf2daccafb --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TleTextTtextPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TleTextTtextPhysicalFunction::TleTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TleTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + Temporal* res = tle_text_ttext(txt, temp); + free(temp); + free(txt); + if (!res) return 0.0; + bool v2 = tbool_start_value(res); + free(res); + return v2 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTleTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TleTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TleTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TleTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TleTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..6e043d7b69 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TleTtextTextPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TleTtextTextPhysicalFunction::TleTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TleTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + Temporal* res = tle_ttext_text(temp, txt); + free(temp); + free(txt); + if (!res) return 0.0; + bool v2 = tbool_start_value(res); + free(res); + return v2 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTleTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TleTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TleTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TltTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TltTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..d304e1ea0d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TltTextTtextPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TltTextTtextPhysicalFunction::TltTextTtextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TltTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref = paramFns[0].execute(record, arena).cast(); + auto value = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* r, uint32_t rsz, const char* v, uint32_t vsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string ref_str(r, rsz); + std::string val_str(v, vsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + Temporal* res = tlt_text_ttext(txt, temp); + free(temp); + free(txt); + if (!res) return 0.0; + bool v2 = tbool_start_value(res); + free(res); + return v2 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref, value, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTltTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TltTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TltTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TltTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TltTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..4d5c15e40a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TltTtextTextPhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TltTtextTextPhysicalFunction::TltTtextTextPhysicalFunction( + PhysicalFunction valueFunction, PhysicalFunction refFunction, PhysicalFunction tsFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(refFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TltTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ref = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* v, uint32_t vsz, const char* r, uint32_t rsz, uint64_t t) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + std::string ref_str(r, rsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size()-1); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size()-1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0.0; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0.0; } + Temporal* res = tlt_ttext_text(temp, txt); + free(temp); + free(txt); + if (!res) return 0.0; + bool v2 = tbool_start_value(res); + free(res); + return v2 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + value, ref, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTltTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TltTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TltTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 72d4d77edb..edd14b8127 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT; sinkClause: INTO sink (',' sink)*; @@ -744,6 +744,14 @@ TEQ_TTEXT_TEXT: 'TEQ_TTEXT_TEXT' | 'teq_ttext_text'; TNE_TTEXT_TEXT: 'TNE_TTEXT_TEXT' | 'tne_ttext_text'; TEQ_TEXT_TTEXT: 'TEQ_TEXT_TTEXT' | 'teq_text_ttext'; TNE_TEXT_TTEXT: 'TNE_TEXT_TTEXT' | 'tne_text_ttext'; +TGE_TTEXT_TEXT: 'TGE_TTEXT_TEXT' | 'tge_ttext_text'; +TGE_TEXT_TTEXT: 'TGE_TEXT_TTEXT' | 'tge_text_ttext'; +TGT_TTEXT_TEXT: 'TGT_TTEXT_TEXT' | 'tgt_ttext_text'; +TGT_TEXT_TTEXT: 'TGT_TEXT_TTEXT' | 'tgt_text_ttext'; +TLE_TTEXT_TEXT: 'TLE_TTEXT_TEXT' | 'tle_ttext_text'; +TLE_TEXT_TTEXT: 'TLE_TEXT_TTEXT' | 'tle_text_ttext'; +TLT_TTEXT_TEXT: 'TLT_TTEXT_TEXT' | 'tlt_ttext_text'; +TLT_TEXT_TTEXT: 'TLT_TEXT_TTEXT' | 'tlt_text_ttext'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 7a0a6c461b..3c75ac3ba3 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -325,6 +325,14 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -8442,6 +8450,238 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TNE_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: TGE_TTEXT_TEXT */ + case AntlrSQLLexer::TGE_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGE_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TgeTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TGE_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: TGE_TEXT_TTEXT */ + case AntlrSQLLexer::TGE_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGE_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TgeTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TGE_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: TGT_TTEXT_TEXT */ + case AntlrSQLLexer::TGT_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGT_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TgtTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TGT_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: TGT_TEXT_TTEXT */ + case AntlrSQLLexer::TGT_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TGT_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TgtTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TGT_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: TLE_TTEXT_TEXT */ + case AntlrSQLLexer::TLE_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLE_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TleTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TLE_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: TLE_TEXT_TTEXT */ + case AntlrSQLLexer::TLE_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLE_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TleTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TLE_TEXT_TTEXT */ + /* BEGIN CODEGEN PARSER GLUE: TLT_TTEXT_TEXT */ + case AntlrSQLLexer::TLT_TTEXT_TEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLT_TTEXT_TEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TltTtextTextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TLT_TTEXT_TEXT */ + /* BEGIN CODEGEN PARSER GLUE: TLT_TEXT_TTEXT */ + case AntlrSQLLexer::TLT_TEXT_TTEXT: + { + const auto argCount = context->expression().size(); + if (argCount != 3) + throw InvalidQuerySyntax("TLT_TEXT_TTEXT requires exactly 3 arguments, but got {}", argCount); + + while (!helpers.top().constantBuilder.empty()) + { + auto constantValue = std::move(helpers.top().constantBuilder.back()); + helpers.top().constantBuilder.pop_back(); + DataType dataType; + char* endPtr = nullptr; + std::strtod(constantValue.c_str(), &endPtr); + if (endPtr != nullptr && *endPtr == '\0') + dataType = DataTypeProvider::provideDataType(DataType::Type::FLOAT64); + else + dataType = DataTypeProvider::provideDataType(DataType::Type::VARSIZED); + helpers.top().functionBuilder.emplace_back(ConstantValueLogicalFunction(dataType, std::move(constantValue))); + } + + auto a2 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a1 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + auto a0 = helpers.top().functionBuilder.back(); helpers.top().functionBuilder.pop_back(); + + helpers.top().functionBuilder.emplace_back(TltTextTtextLogicalFunction(a0, a1, a2)); + } + break; + /* END CODEGEN PARSER GLUE: TLT_TEXT_TTEXT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From de81222ba945d67517bf37d168010b397b004abc Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Sun, 14 Jun 2026 09:10:17 +0200 Subject: [PATCH 44/86] feat(meos): add TTEXT_UPPER/LOWER/INITCAP NES operators (W95) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wire ttext_upper, ttext_lower, and ttext_initcap as per-event scalar NES operators. Each takes (value:VARCHAR, ts:UINT64) and returns VARCHAR. The physical functions pre-allocate a 4096-byte arena buffer, call the MEOS function inside nautilus::invoke writing into the buffer, and write the actual byte length back via VarVal::writeToMemory — the first VARCHAR-return scalar pattern in this harness. --- .../Meos/TtextInitcapLogicalFunction.hpp | 52 +++++++++ .../Meos/TtextLowerLogicalFunction.hpp | 52 +++++++++ .../Meos/TtextUpperLogicalFunction.hpp | 52 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../Meos/TtextInitcapLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/TtextLowerLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/TtextUpperLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/TtextInitcapPhysicalFunction.hpp | 35 ++++++ .../Meos/TtextLowerPhysicalFunction.hpp | 35 ++++++ .../Meos/TtextUpperPhysicalFunction.hpp | 35 ++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../Meos/TtextInitcapPhysicalFunction.cpp | 98 +++++++++++++++++ .../Meos/TtextLowerPhysicalFunction.cpp | 98 +++++++++++++++++ .../Meos/TtextUpperPhysicalFunction.cpp | 98 +++++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 5 +- .../src/AntlrSQLQueryPlanCreator.cpp | 30 ++++++ 16 files changed, 901 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TtextInitcapLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TtextLowerLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TtextUpperLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TtextInitcapLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TtextLowerLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TtextUpperLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TtextInitcapPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TtextLowerPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TtextUpperPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TtextInitcapPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TtextLowerPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TtextUpperPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TtextInitcapLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TtextInitcapLogicalFunction.hpp new file mode 100644 index 0000000000..3e85db4bba --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TtextInitcapLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ttext_initcap: single-instant ttext transform -> varchar. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ttext_initcap`. Per-event scalar operator; returns the transformed text value. + */ +class TtextInitcapLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TtextInitcap"; + + TtextInitcapLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TtextLowerLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TtextLowerLogicalFunction.hpp new file mode 100644 index 0000000000..45e44997d6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TtextLowerLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ttext_lower: single-instant ttext transform -> varchar. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ttext_lower`. Per-event scalar operator; returns the transformed text value. + */ +class TtextLowerLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TtextLower"; + + TtextLowerLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TtextUpperLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TtextUpperLogicalFunction.hpp new file mode 100644 index 0000000000..99766bbe6b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TtextUpperLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event ttext_upper: single-instant ttext transform -> varchar. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `ttext_upper`. Per-event scalar operator; returns the transformed text value. + */ +class TtextUpperLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TtextUpper"; + + TtextUpperLogicalFunction(LogicalFunction value, + LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 367216d983..7201206e54 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -282,3 +282,6 @@ add_plugin(TleTtextText LogicalFunction nes-logical-operators TleTtextTextLogica add_plugin(TleTextTtext LogicalFunction nes-logical-operators TleTextTtextLogicalFunction.cpp) add_plugin(TltTtextText LogicalFunction nes-logical-operators TltTtextTextLogicalFunction.cpp) add_plugin(TltTextTtext LogicalFunction nes-logical-operators TltTextTtextLogicalFunction.cpp) +add_plugin(TtextUpper LogicalFunction nes-logical-operators TtextUpperLogicalFunction.cpp) +add_plugin(TtextLower LogicalFunction nes-logical-operators TtextLowerLogicalFunction.cpp) +add_plugin(TtextInitcap LogicalFunction nes-logical-operators TtextInitcapLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TtextInitcapLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TtextInitcapLogicalFunction.cpp new file mode 100644 index 0000000000..9e3fc38f7c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TtextInitcapLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TtextInitcapLogicalFunction::TtextInitcapLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TtextInitcapLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TtextInitcapLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TtextInitcapLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TtextInitcapLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TtextInitcapLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TtextInitcapLogicalFunction::getType() const { return NAME; } + +bool TtextInitcapLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TtextInitcapLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TtextInitcapLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TtextInitcapLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTtextInitcapLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TtextInitcapLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TtextInitcapLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TtextLowerLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TtextLowerLogicalFunction.cpp new file mode 100644 index 0000000000..f171eb7600 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TtextLowerLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TtextLowerLogicalFunction::TtextLowerLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TtextLowerLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TtextLowerLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TtextLowerLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TtextLowerLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TtextLowerLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TtextLowerLogicalFunction::getType() const { return NAME; } + +bool TtextLowerLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TtextLowerLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TtextLowerLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TtextLowerLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTtextLowerLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TtextLowerLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TtextLowerLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TtextUpperLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TtextUpperLogicalFunction.cpp new file mode 100644 index 0000000000..8e68f39a99 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TtextUpperLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TtextUpperLogicalFunction::TtextUpperLogicalFunction(LogicalFunction value, + LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); +} + +DataType TtextUpperLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TtextUpperLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TtextUpperLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TtextUpperLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "TtextUpperLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TtextUpperLogicalFunction::getType() const { return NAME; } + +bool TtextUpperLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TtextUpperLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TtextUpperLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TtextUpperLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTtextUpperLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "TtextUpperLogicalFunction requires 2 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + return TtextUpperLogicalFunction(std::move(arg0), std::move(arg1)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TtextInitcapPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TtextInitcapPhysicalFunction.hpp new file mode 100644 index 0000000000..3d04a89181 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TtextInitcapPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TtextInitcapPhysicalFunction : public PhysicalFunctionConcept { +public: + TtextInitcapPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TtextLowerPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TtextLowerPhysicalFunction.hpp new file mode 100644 index 0000000000..8605f87d65 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TtextLowerPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TtextLowerPhysicalFunction : public PhysicalFunctionConcept { +public: + TtextLowerPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TtextUpperPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TtextUpperPhysicalFunction.hpp new file mode 100644 index 0000000000..aa98369b8d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TtextUpperPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TtextUpperPhysicalFunction : public PhysicalFunctionConcept { +public: + TtextUpperPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 4dd15337c1..2711a002fb 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -281,4 +281,7 @@ add_plugin(TleTtextText PhysicalFunction nes-physical-operators TleTtextTextPhys add_plugin(TleTextTtext PhysicalFunction nes-physical-operators TleTextTtextPhysicalFunction.cpp) add_plugin(TltTtextText PhysicalFunction nes-physical-operators TltTtextTextPhysicalFunction.cpp) add_plugin(TltTextTtext PhysicalFunction nes-physical-operators TltTextTtextPhysicalFunction.cpp) +add_plugin(TtextUpper PhysicalFunction nes-physical-operators TtextUpperPhysicalFunction.cpp) +add_plugin(TtextLower PhysicalFunction nes-physical-operators TtextLowerPhysicalFunction.cpp) +add_plugin(TtextInitcap PhysicalFunction nes-physical-operators TtextInitcapPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TtextInitcapPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TtextInitcapPhysicalFunction.cpp new file mode 100644 index 0000000000..54f48e699e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TtextInitcapPhysicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TtextInitcapPhysicalFunction::TtextInitcapPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TtextInitcapPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast>(); + + constexpr uint32_t MAX_LEN = 4096; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* v, uint32_t vsz, uint64_t t, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) + val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) + val_str = val_str.substr(0, val_str.size() - 1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0u; + Temporal* res = ttext_initcap(temp); + free(temp); + if (!res) return 0u; + text* txt = ttext_start_value(res); + free(res); + if (!txt) return 0u; + char* cstr = text_to_cstring(txt); + free(txt); + if (!cstr) return 0u; + uint32_t len = static_cast(std::strlen(cstr)); + if (len > bufMax) len = bufMax; + std::memcpy(buf, cstr, len); + free(cstr); + return len; + } catch (const std::exception&) { return 0u; } + }, + value, ts, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTtextInitcapPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TtextInitcapPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return TtextInitcapPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TtextLowerPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TtextLowerPhysicalFunction.cpp new file mode 100644 index 0000000000..16ef19011a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TtextLowerPhysicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TtextLowerPhysicalFunction::TtextLowerPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TtextLowerPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast>(); + + constexpr uint32_t MAX_LEN = 4096; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* v, uint32_t vsz, uint64_t t, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) + val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) + val_str = val_str.substr(0, val_str.size() - 1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0u; + Temporal* res = ttext_lower(temp); + free(temp); + if (!res) return 0u; + text* txt = ttext_start_value(res); + free(res); + if (!txt) return 0u; + char* cstr = text_to_cstring(txt); + free(txt); + if (!cstr) return 0u; + uint32_t len = static_cast(std::strlen(cstr)); + if (len > bufMax) len = bufMax; + std::memcpy(buf, cstr, len); + free(cstr); + return len; + } catch (const std::exception&) { return 0u; } + }, + value, ts, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTtextLowerPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TtextLowerPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return TtextLowerPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TtextUpperPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TtextUpperPhysicalFunction.cpp new file mode 100644 index 0000000000..9c4e91e507 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TtextUpperPhysicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TtextUpperPhysicalFunction::TtextUpperPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(tsFunction)); +} + +VarVal TtextUpperPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast>(); + + constexpr uint32_t MAX_LEN = 4096; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* v, uint32_t vsz, uint64_t t, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) + val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) + val_str = val_str.substr(0, val_str.size() - 1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0u; + Temporal* res = ttext_upper(temp); + free(temp); + if (!res) return 0u; + text* txt = ttext_start_value(res); + free(res); + if (!txt) return 0u; + char* cstr = text_to_cstring(txt); + free(txt); + if (!cstr) return 0u; + uint32_t len = static_cast(std::strlen(cstr)); + if (len > bufMax) len = bufMax; + std::memcpy(buf, cstr, len); + free(cstr); + return len; + } catch (const std::exception&) { return 0u; } + }, + value, ts, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTtextUpperPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "TtextUpperPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return TtextUpperPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index edd14b8127..060d99ae34 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP; sinkClause: INTO sink (',' sink)*; @@ -752,6 +752,9 @@ TLE_TTEXT_TEXT: 'TLE_TTEXT_TEXT' | 'tle_ttext_text'; TLE_TEXT_TTEXT: 'TLE_TEXT_TTEXT' | 'tle_text_ttext'; TLT_TTEXT_TEXT: 'TLT_TTEXT_TEXT' | 'tlt_ttext_text'; TLT_TEXT_TTEXT: 'TLT_TEXT_TTEXT' | 'tlt_text_ttext'; +TTEXT_UPPER: 'TTEXT_UPPER' | 'ttext_upper'; +TTEXT_LOWER: 'TTEXT_LOWER' | 'ttext_lower'; +TTEXT_INITCAP: 'TTEXT_INITCAP' | 'ttext_initcap'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 3c75ac3ba3..890352ac53 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -333,6 +333,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -8682,6 +8685,33 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont } break; /* END CODEGEN PARSER GLUE: TLT_TEXT_TTEXT */ + case AntlrSQLParser::TTEXT_UPPER: { + PRECONDITION(ctx->functionParam().size() == 2, + "TtextUpper requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(TtextUpperLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: TTEXT_UPPER */ + case AntlrSQLParser::TTEXT_LOWER: { + PRECONDITION(ctx->functionParam().size() == 2, + "TtextLower requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(TtextLowerLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: TTEXT_LOWER */ + case AntlrSQLParser::TTEXT_INITCAP: { + PRECONDITION(ctx->functionParam().size() == 2, + "TtextInitcap requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(TtextInitcapLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: TTEXT_INITCAP */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From d5eb335d15f627d54e85bfda55356ec480e120e7 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Sun, 14 Jun 2026 12:00:22 +0200 Subject: [PATCH 45/86] feat(meos): add TEXTCAT_{TTEXT_TEXT,TEXT_TTEXT,TTEXT_TTEXT} NES operators (W96) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wire textcat_ttext_text (3-arg: value,ts,ref → varchar), textcat_text_ttext (3-arg: value,ts,ref → varchar; text operand first in MEOS call), and textcat_ttext_ttext (4-arg: value1,ts1,value2,ts2 → varchar; first 4-arg operator in this harness) as per-event scalar NES operators. All three return VARCHAR via the arena allocateVariableSizedData buffer-fill pattern established in W95. --- .../Meos/TextcatTextTtextLogicalFunction.hpp | 51 ++++++++ .../Meos/TextcatTtextTextLogicalFunction.hpp | 51 ++++++++ .../Meos/TextcatTtextTtextLogicalFunction.hpp | 51 ++++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../Meos/TextcatTextTtextLogicalFunction.cpp | 103 ++++++++++++++++ .../Meos/TextcatTtextTextLogicalFunction.cpp | 103 ++++++++++++++++ .../Meos/TextcatTtextTtextLogicalFunction.cpp | 105 ++++++++++++++++ .../Meos/TextcatTextTtextPhysicalFunction.hpp | 34 ++++++ .../Meos/TextcatTtextTextPhysicalFunction.hpp | 34 ++++++ .../TextcatTtextTtextPhysicalFunction.hpp | 34 ++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../Meos/TextcatTextTtextPhysicalFunction.cpp | 105 ++++++++++++++++ .../Meos/TextcatTtextTextPhysicalFunction.cpp | 105 ++++++++++++++++ .../TextcatTtextTtextPhysicalFunction.cpp | 112 ++++++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 5 +- .../src/AntlrSQLQueryPlanCreator.cpp | 34 ++++++ 16 files changed, 932 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/TextcatTextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TextcatTtextTextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/TextcatTtextTtextLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/TextcatTextTtextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TextcatTtextTextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/TextcatTtextTtextLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/TextcatTextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TextcatTtextTextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/TextcatTtextTtextPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/TextcatTextTtextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TextcatTtextTextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/TextcatTtextTtextPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/TextcatTextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TextcatTextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..3981a46b60 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TextcatTextTtextLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event textcat_text_ttext: (value:VARCHAR, ts:UINT64, ref:VARCHAR) -> varchar. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `textcat_text_ttext`. Per-event scalar operator returning VARCHAR. + */ +class TextcatTextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TextcatTextTtext"; + + TextcatTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ts, LogicalFunction ref); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TextcatTtextTextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TextcatTtextTextLogicalFunction.hpp new file mode 100644 index 0000000000..319280c933 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TextcatTtextTextLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event textcat_ttext_text: (value:VARCHAR, ts:UINT64, ref:VARCHAR) -> varchar. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `textcat_ttext_text`. Per-event scalar operator returning VARCHAR. + */ +class TextcatTtextTextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TextcatTtextText"; + + TextcatTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ts, LogicalFunction ref); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/TextcatTtextTtextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/TextcatTtextTtextLogicalFunction.hpp new file mode 100644 index 0000000000..1e6b12cd06 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/TextcatTtextTtextLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Per-event textcat_ttext_ttext: (value1:VARCHAR, ts1:UINT64, value2:VARCHAR, ts2:UINT64) -> varchar. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `textcat_ttext_ttext`. Per-event scalar operator returning VARCHAR. + */ +class TextcatTtextTtextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "TextcatTtextTtext"; + + TextcatTtextTtextLogicalFunction(LogicalFunction value1, LogicalFunction ts1, LogicalFunction value2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 7201206e54..6d7f4b27fd 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -285,3 +285,6 @@ add_plugin(TltTextTtext LogicalFunction nes-logical-operators TltTextTtextLogica add_plugin(TtextUpper LogicalFunction nes-logical-operators TtextUpperLogicalFunction.cpp) add_plugin(TtextLower LogicalFunction nes-logical-operators TtextLowerLogicalFunction.cpp) add_plugin(TtextInitcap LogicalFunction nes-logical-operators TtextInitcapLogicalFunction.cpp) +add_plugin(TextcatTtextText LogicalFunction nes-logical-operators TextcatTtextTextLogicalFunction.cpp) +add_plugin(TextcatTextTtext LogicalFunction nes-logical-operators TextcatTextTtextLogicalFunction.cpp) +add_plugin(TextcatTtextTtext LogicalFunction nes-logical-operators TextcatTtextTtextLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/TextcatTextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TextcatTextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..9b7be445b6 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TextcatTextTtextLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TextcatTextTtextLogicalFunction::TextcatTextTtextLogicalFunction(LogicalFunction value, LogicalFunction ts, LogicalFunction ref) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(ref)); +} + +DataType TextcatTextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TextcatTextTtextLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TextcatTextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TextcatTextTtextLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TextcatTextTtextLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TextcatTextTtextLogicalFunction::getType() const { return NAME; } + +bool TextcatTextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TextcatTextTtextLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TextcatTextTtextLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TextcatTextTtextLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTextcatTextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TextcatTextTtextLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TextcatTextTtextLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TextcatTtextTextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TextcatTtextTextLogicalFunction.cpp new file mode 100644 index 0000000000..db6687cd5a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TextcatTtextTextLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TextcatTtextTextLogicalFunction::TextcatTtextTextLogicalFunction(LogicalFunction value, LogicalFunction ts, LogicalFunction ref) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(3); + parameters.push_back(std::move(value)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(ref)); +} + +DataType TextcatTtextTextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TextcatTtextTextLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TextcatTtextTextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TextcatTtextTextLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "TextcatTtextTextLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TextcatTtextTextLogicalFunction::getType() const { return NAME; } + +bool TextcatTtextTextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TextcatTtextTextLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TextcatTtextTextLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TextcatTtextTextLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTextcatTtextTextLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "TextcatTtextTextLogicalFunction requires 3 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + return TextcatTtextTextLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2)); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/TextcatTtextTtextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/TextcatTtextTtextLogicalFunction.cpp new file mode 100644 index 0000000000..f806a02d5f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/TextcatTtextTtextLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +TextcatTtextTtextLogicalFunction::TextcatTtextTtextLogicalFunction(LogicalFunction value1, LogicalFunction ts1, LogicalFunction value2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(4); + parameters.push_back(std::move(value1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(value2)); + parameters.push_back(std::move(ts2)); +} + +DataType TextcatTtextTtextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction TextcatTtextTtextLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector TextcatTtextTtextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction TextcatTtextTtextLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, "TextcatTtextTtextLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view TextcatTtextTtextLogicalFunction::getType() const { return NAME; } + +bool TextcatTtextTtextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string TextcatTtextTtextLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction TextcatTtextTtextLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction TextcatTtextTtextLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTextcatTtextTtextLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "TextcatTtextTtextLogicalFunction requires 4 children but got {}", + arguments.children.size()); + auto arg0 = std::move(arguments.children[0]); + auto arg1 = std::move(arguments.children[1]); + auto arg2 = std::move(arguments.children[2]); + auto arg3 = std::move(arguments.children[3]); + return TextcatTtextTtextLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3)); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TextcatTextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TextcatTextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..ea60fa0eb5 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TextcatTextTtextPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TextcatTextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + TextcatTextTtextPhysicalFunction(PhysicalFunction valueFunction, PhysicalFunction tsFunction, PhysicalFunction refFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TextcatTtextTextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TextcatTtextTextPhysicalFunction.hpp new file mode 100644 index 0000000000..48fc8bad05 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TextcatTtextTextPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TextcatTtextTextPhysicalFunction : public PhysicalFunctionConcept { +public: + TextcatTtextTextPhysicalFunction(PhysicalFunction valueFunction, PhysicalFunction tsFunction, PhysicalFunction refFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/TextcatTtextTtextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/TextcatTtextTtextPhysicalFunction.hpp new file mode 100644 index 0000000000..f5ebc98ff6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/TextcatTtextTtextPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class TextcatTtextTtextPhysicalFunction : public PhysicalFunctionConcept { +public: + TextcatTtextTtextPhysicalFunction(PhysicalFunction value1Function, PhysicalFunction ts1Function, PhysicalFunction value2Function, PhysicalFunction ts2Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 2711a002fb..b98134091c 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -284,4 +284,7 @@ add_plugin(TltTextTtext PhysicalFunction nes-physical-operators TltTextTtextPhys add_plugin(TtextUpper PhysicalFunction nes-physical-operators TtextUpperPhysicalFunction.cpp) add_plugin(TtextLower PhysicalFunction nes-physical-operators TtextLowerPhysicalFunction.cpp) add_plugin(TtextInitcap PhysicalFunction nes-physical-operators TtextInitcapPhysicalFunction.cpp) +add_plugin(TextcatTtextText PhysicalFunction nes-physical-operators TextcatTtextTextPhysicalFunction.cpp) +add_plugin(TextcatTextTtext PhysicalFunction nes-physical-operators TextcatTextTtextPhysicalFunction.cpp) +add_plugin(TextcatTtextTtext PhysicalFunction nes-physical-operators TextcatTtextTtextPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/TextcatTextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TextcatTextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..7c65dcbbd4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TextcatTextTtextPhysicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TextcatTextTtextPhysicalFunction::TextcatTextTtextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction refFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(tsFunction)); + paramFns.push_back(std::move(refFunction)); +} + +VarVal TextcatTextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast>(); + auto ref = paramFns[2].execute(record, arena).cast(); + + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* v, uint32_t vsz, uint64_t t, const char* r, uint32_t rsz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size() - 1); + std::string ref_str(r, rsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size() - 1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0u; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0u; } + Temporal* res = textcat_text_ttext(txt, temp); + free(temp); free(txt); + if (!res) return 0u; + text* out_txt = ttext_start_value(res); + free(res); + if (!out_txt) return 0u; + char* cstr = text_to_cstring(out_txt); + free(out_txt); + if (!cstr) return 0u; + uint32_t len = static_cast(std::strlen(cstr)); + if (len > bufMax) len = bufMax; + std::memcpy(buf, cstr, len); + free(cstr); + return len; + } catch (const std::exception&) { return 0u; } + }, + value, ts, ref, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTextcatTextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TextcatTextTtextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TextcatTextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TextcatTtextTextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TextcatTtextTextPhysicalFunction.cpp new file mode 100644 index 0000000000..3b4d396a5b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TextcatTtextTextPhysicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TextcatTtextTextPhysicalFunction::TextcatTtextTextPhysicalFunction(PhysicalFunction valueFunction, + PhysicalFunction tsFunction, + PhysicalFunction refFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(valueFunction)); + paramFns.push_back(std::move(tsFunction)); + paramFns.push_back(std::move(refFunction)); +} + +VarVal TextcatTtextTextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast>(); + auto ref = paramFns[2].execute(record, arena).cast(); + + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* v, uint32_t vsz, uint64_t t, const char* r, uint32_t rsz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string val_str(v, vsz); + while (!val_str.empty() && (val_str.front() == '\'' || val_str.front() == '"')) val_str = val_str.substr(1); + while (!val_str.empty() && (val_str.back() == '\'' || val_str.back() == '"')) val_str = val_str.substr(0, val_str.size() - 1); + std::string ref_str(r, rsz); + while (!ref_str.empty() && (ref_str.front() == '\'' || ref_str.front() == '"')) ref_str = ref_str.substr(1); + while (!ref_str.empty() && (ref_str.back() == '\'' || ref_str.back() == '"')) ref_str = ref_str.substr(0, ref_str.size() - 1); + std::string ts_str = MEOS::Meos::convertEpochToTimestamp(t); + std::string wkt = "'" + val_str + "'@" + ts_str; + Temporal* temp = ttext_in(wkt.c_str()); + if (!temp) return 0u; + text* txt = cstring_to_text(ref_str.c_str()); + if (!txt) { free(temp); return 0u; } + Temporal* res = textcat_ttext_text(temp, txt); + free(temp); free(txt); + if (!res) return 0u; + text* out_txt = ttext_start_value(res); + free(res); + if (!out_txt) return 0u; + char* cstr = text_to_cstring(out_txt); + free(out_txt); + if (!cstr) return 0u; + uint32_t len = static_cast(std::strlen(cstr)); + if (len > bufMax) len = bufMax; + std::memcpy(buf, cstr, len); + free(cstr); + return len; + } catch (const std::exception&) { return 0u; } + }, + value, ts, ref, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTextcatTtextTextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "TextcatTtextTextPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return TextcatTtextTextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/TextcatTtextTtextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/TextcatTtextTtextPhysicalFunction.cpp new file mode 100644 index 0000000000..ed92d1e6e4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/TextcatTtextTtextPhysicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace NES { + +TextcatTtextTtextPhysicalFunction::TextcatTtextTtextPhysicalFunction(PhysicalFunction value1Function, + PhysicalFunction ts1Function, + PhysicalFunction value2Function, + PhysicalFunction ts2Function) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(value1Function)); + paramFns.push_back(std::move(ts1Function)); + paramFns.push_back(std::move(value2Function)); + paramFns.push_back(std::move(ts2Function)); +} + +VarVal TextcatTtextTtextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto value1 = paramFns[0].execute(record, arena).cast(); + auto ts1 = paramFns[1].execute(record, arena).cast>(); + auto value2 = paramFns[2].execute(record, arena).cast(); + auto ts2 = paramFns[3].execute(record, arena).cast>(); + + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* v1, uint32_t v1sz, uint64_t t1, + const char* v2, uint32_t v2sz, uint64_t t2, + char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + auto strip = [](std::string s) { + while (!s.empty() && (s.front() == '\'' || s.front() == '"')) s = s.substr(1); + while (!s.empty() && (s.back() == '\'' || s.back() == '"')) s = s.substr(0, s.size() - 1); + return s; + }; + std::string s1 = strip(std::string(v1, v1sz)); + std::string s2 = strip(std::string(v2, v2sz)); + std::string ts1_str = MEOS::Meos::convertEpochToTimestamp(t1); + std::string ts2_str = MEOS::Meos::convertEpochToTimestamp(t2); + Temporal* temp1 = ttext_in(("'" + s1 + "'@" + ts1_str).c_str()); + if (!temp1) return 0u; + Temporal* temp2 = ttext_in(("'" + s2 + "'@" + ts2_str).c_str()); + if (!temp2) { free(temp1); return 0u; } + Temporal* res = textcat_ttext_ttext(temp1, temp2); + free(temp1); free(temp2); + if (!res) return 0u; + text* out_txt = ttext_start_value(res); + free(res); + if (!out_txt) return 0u; + char* cstr = text_to_cstring(out_txt); + free(out_txt); + if (!cstr) return 0u; + uint32_t len = static_cast(std::strlen(cstr)); + if (len > bufMax) len = bufMax; + std::memcpy(buf, cstr, len); + free(cstr); + return len; + } catch (const std::exception&) { return 0u; } + }, + value1, ts1, value2, ts2, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTextcatTtextTtextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "TextcatTtextTtextPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return TextcatTtextTtextPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 060d99ae34..4ea0dfc476 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT; sinkClause: INTO sink (',' sink)*; @@ -755,6 +755,9 @@ TLT_TEXT_TTEXT: 'TLT_TEXT_TTEXT' | 'tlt_text_ttext'; TTEXT_UPPER: 'TTEXT_UPPER' | 'ttext_upper'; TTEXT_LOWER: 'TTEXT_LOWER' | 'ttext_lower'; TTEXT_INITCAP: 'TTEXT_INITCAP' | 'ttext_initcap'; +TEXTCAT_TTEXT_TEXT: 'TEXTCAT_TTEXT_TEXT' | 'textcat_ttext_text'; +TEXTCAT_TEXT_TTEXT: 'TEXTCAT_TEXT_TTEXT' | 'textcat_text_ttext'; +TEXTCAT_TTEXT_TTEXT: 'TEXTCAT_TTEXT_TTEXT' | 'textcat_ttext_ttext'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 890352ac53..3f9dfbfced 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -336,6 +336,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -8712,6 +8715,37 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(TtextInitcapLogicalFunction(std::move(arg0), std::move(arg1))); } /* END CODEGEN PARSER GLUE: TTEXT_INITCAP */ + case AntlrSQLParser::TEXTCAT_TTEXT_TEXT: { + PRECONDITION(ctx->functionParam().size() == 3, + "TextcatTtextText requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(TextcatTtextTextLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: TEXTCAT_TTEXT_TEXT */ + case AntlrSQLParser::TEXTCAT_TEXT_TTEXT: { + PRECONDITION(ctx->functionParam().size() == 3, + "TextcatTextTtext requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(TextcatTextTtextLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: TEXTCAT_TEXT_TTEXT */ + case AntlrSQLParser::TEXTCAT_TTEXT_TTEXT: { + PRECONDITION(ctx->functionParam().size() == 4, + "TextcatTtextTtext requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(TextcatTtextTtextLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: TEXTCAT_TTEXT_TTEXT */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 4214477ca704ec8470d9de7e88ab1ca7fd508199 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Sun, 14 Jun 2026 12:03:44 +0200 Subject: [PATCH 46/86] feat(meos): add GEOM_{INTERSECTS2D,DWITHIN2D,CONTAINS,DISJOINT2D} NES operators (W97) Wire geom_intersects2d, geom_dwithin2d, geom_contains, and geom_disjoint2d as per-event scalar NES operators on plain WKT geometry strings (no temporal dimension). The 2-arg predicates take (wkt1:VARCHAR, wkt2:VARCHAR) and the 3-arg geom_dwithin2d adds dist:FLOAT64. All return FLOAT64 0/1 via geom_in to GSERIALIZED* conversion inside nautilus::invoke. --- .../Meos/GeomContainsLogicalFunction.hpp | 51 +++++++++ .../Meos/GeomDisjoint2dLogicalFunction.hpp | 51 +++++++++ .../Meos/GeomDwithin2dLogicalFunction.hpp | 51 +++++++++ .../Meos/GeomIntersects2dLogicalFunction.hpp | 51 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/GeomContainsLogicalFunction.cpp | 101 +++++++++++++++++ .../Meos/GeomDisjoint2dLogicalFunction.cpp | 101 +++++++++++++++++ .../Meos/GeomDwithin2dLogicalFunction.cpp | 103 ++++++++++++++++++ .../Meos/GeomIntersects2dLogicalFunction.cpp | 101 +++++++++++++++++ .../Meos/GeomContainsPhysicalFunction.hpp | 34 ++++++ .../Meos/GeomDisjoint2dPhysicalFunction.hpp | 34 ++++++ .../Meos/GeomDwithin2dPhysicalFunction.hpp | 34 ++++++ .../Meos/GeomIntersects2dPhysicalFunction.hpp | 34 ++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/GeomContainsPhysicalFunction.cpp | 80 ++++++++++++++ .../Meos/GeomDisjoint2dPhysicalFunction.cpp | 80 ++++++++++++++ .../Meos/GeomDwithin2dPhysicalFunction.cpp | 84 ++++++++++++++ .../Meos/GeomIntersects2dPhysicalFunction.cpp | 80 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 41 +++++++ 20 files changed, 1124 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeomContainsLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomDisjoint2dLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomDwithin2dLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomIntersects2dLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomContainsLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomDisjoint2dLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomDwithin2dLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomIntersects2dLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomContainsPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomDisjoint2dPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomDwithin2dPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomIntersects2dPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomContainsPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomDisjoint2dPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomDwithin2dPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomIntersects2dPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeomContainsLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomContainsLogicalFunction.hpp new file mode 100644 index 0000000000..01a4f5f17b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomContainsLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Static geometry predicate geom_contains: (wkt1:VARCHAR, wkt2:VARCHAR) -> float64 (0/1). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `geom_contains`. Operates on plain WKT strings without a temporal dimension. + */ +class GeomContainsLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomContains"; + + GeomContainsLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomDisjoint2dLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomDisjoint2dLogicalFunction.hpp new file mode 100644 index 0000000000..972e387900 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomDisjoint2dLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Static geometry predicate geom_disjoint2d: (wkt1:VARCHAR, wkt2:VARCHAR) -> float64 (0/1). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `geom_disjoint2d`. Operates on plain WKT strings without a temporal dimension. + */ +class GeomDisjoint2dLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomDisjoint2d"; + + GeomDisjoint2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomDwithin2dLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomDwithin2dLogicalFunction.hpp new file mode 100644 index 0000000000..c0f16054c4 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomDwithin2dLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Static geometry predicate geom_dwithin2d: (wkt1:VARCHAR, wkt2:VARCHAR, dist:FLOAT64) -> float64 (0/1). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `geom_dwithin2d`. Operates on plain WKT strings without a temporal dimension. + */ +class GeomDwithin2dLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomDwithin2d"; + + GeomDwithin2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2, LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomIntersects2dLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomIntersects2dLogicalFunction.hpp new file mode 100644 index 0000000000..30df4ef297 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomIntersects2dLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Static geometry predicate geom_intersects2d: (wkt1:VARCHAR, wkt2:VARCHAR) -> float64 (0/1). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function + * `geom_intersects2d`. Operates on plain WKT strings without a temporal dimension. + */ +class GeomIntersects2dLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomIntersects2d"; + + GeomIntersects2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 6d7f4b27fd..2c99730b1c 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -288,3 +288,7 @@ add_plugin(TtextInitcap LogicalFunction nes-logical-operators TtextInitcapLogica add_plugin(TextcatTtextText LogicalFunction nes-logical-operators TextcatTtextTextLogicalFunction.cpp) add_plugin(TextcatTextTtext LogicalFunction nes-logical-operators TextcatTextTtextLogicalFunction.cpp) add_plugin(TextcatTtextTtext LogicalFunction nes-logical-operators TextcatTtextTtextLogicalFunction.cpp) +add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) +add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) +add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) +add_plugin(GeomDisjoint2d LogicalFunction nes-logical-operators GeomDisjoint2dLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeomContainsLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomContainsLogicalFunction.cpp new file mode 100644 index 0000000000..e4bac6c415 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomContainsLogicalFunction.cpp @@ -0,0 +1,101 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomContainsLogicalFunction::GeomContainsLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomContainsLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomContainsLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomContainsLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomContainsLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "GeomContainsLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomContainsLogicalFunction::getType() const { return NAME; } + +bool GeomContainsLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomContainsLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction GeomContainsLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction GeomContainsLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomContainsLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomContainsLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomContainsLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomDisjoint2dLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomDisjoint2dLogicalFunction.cpp new file mode 100644 index 0000000000..9354460dd0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomDisjoint2dLogicalFunction.cpp @@ -0,0 +1,101 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomDisjoint2dLogicalFunction::GeomDisjoint2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomDisjoint2dLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomDisjoint2dLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomDisjoint2dLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomDisjoint2dLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "GeomDisjoint2dLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomDisjoint2dLogicalFunction::getType() const { return NAME; } + +bool GeomDisjoint2dLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomDisjoint2dLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction GeomDisjoint2dLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction GeomDisjoint2dLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomDisjoint2dLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomDisjoint2dLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomDisjoint2dLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomDwithin2dLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomDwithin2dLogicalFunction.cpp new file mode 100644 index 0000000000..e91b1f61bb --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomDwithin2dLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomDwithin2dLogicalFunction::GeomDwithin2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2, LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); + parameters.push_back(std::move(dist)); +} + +DataType GeomDwithin2dLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomDwithin2dLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomDwithin2dLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomDwithin2dLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "GeomDwithin2dLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomDwithin2dLogicalFunction::getType() const { return NAME; } + +bool GeomDwithin2dLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomDwithin2dLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction GeomDwithin2dLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction GeomDwithin2dLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomDwithin2dLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "GeomDwithin2dLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return GeomDwithin2dLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomIntersects2dLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomIntersects2dLogicalFunction.cpp new file mode 100644 index 0000000000..ddef3d58ed --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomIntersects2dLogicalFunction.cpp @@ -0,0 +1,101 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomIntersects2dLogicalFunction::GeomIntersects2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomIntersects2dLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomIntersects2dLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomIntersects2dLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomIntersects2dLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "GeomIntersects2dLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomIntersects2dLogicalFunction::getType() const { return NAME; } + +bool GeomIntersects2dLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomIntersects2dLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction GeomIntersects2dLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction GeomIntersects2dLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomIntersects2dLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomIntersects2dLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomIntersects2dLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomContainsPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomContainsPhysicalFunction.hpp new file mode 100644 index 0000000000..4ddd7fdc80 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomContainsPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomContainsPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomContainsPhysicalFunction(PhysicalFunction wkt1Function, PhysicalFunction wkt2Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomDisjoint2dPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomDisjoint2dPhysicalFunction.hpp new file mode 100644 index 0000000000..b503ce25b0 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomDisjoint2dPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomDisjoint2dPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomDisjoint2dPhysicalFunction(PhysicalFunction wkt1Function, PhysicalFunction wkt2Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomDwithin2dPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomDwithin2dPhysicalFunction.hpp new file mode 100644 index 0000000000..d2410721bc --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomDwithin2dPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomDwithin2dPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomDwithin2dPhysicalFunction(PhysicalFunction wkt1Function, PhysicalFunction wkt2Function, PhysicalFunction distFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomIntersects2dPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomIntersects2dPhysicalFunction.hpp new file mode 100644 index 0000000000..2aba593ea7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomIntersects2dPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomIntersects2dPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomIntersects2dPhysicalFunction(PhysicalFunction wkt1Function, PhysicalFunction wkt2Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index b98134091c..4701e0568c 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -287,4 +287,8 @@ add_plugin(TtextInitcap PhysicalFunction nes-physical-operators TtextInitcapPhys add_plugin(TextcatTtextText PhysicalFunction nes-physical-operators TextcatTtextTextPhysicalFunction.cpp) add_plugin(TextcatTextTtext PhysicalFunction nes-physical-operators TextcatTextTtextPhysicalFunction.cpp) add_plugin(TextcatTtextTtext PhysicalFunction nes-physical-operators TextcatTtextTtextPhysicalFunction.cpp) +add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) +add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) +add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) +add_plugin(GeomDisjoint2d PhysicalFunction nes-physical-operators GeomDisjoint2dPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/GeomContainsPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomContainsPhysicalFunction.cpp new file mode 100644 index 0000000000..f72e9879d9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomContainsPhysicalFunction.cpp @@ -0,0 +1,80 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomContainsPhysicalFunction::GeomContainsPhysicalFunction(PhysicalFunction wkt1Function, + PhysicalFunction wkt2Function) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1Function)); + paramFns.push_back(std::move(wkt2Function)); +} + +VarVal GeomContainsPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + bool r = geom_contains(gs1, gs2); + free(gs1); free(gs2); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + wkt1, wkt2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomContainsPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomContainsPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomContainsPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomDisjoint2dPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomDisjoint2dPhysicalFunction.cpp new file mode 100644 index 0000000000..83741db21b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomDisjoint2dPhysicalFunction.cpp @@ -0,0 +1,80 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomDisjoint2dPhysicalFunction::GeomDisjoint2dPhysicalFunction(PhysicalFunction wkt1Function, + PhysicalFunction wkt2Function) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1Function)); + paramFns.push_back(std::move(wkt2Function)); +} + +VarVal GeomDisjoint2dPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + bool r = geom_disjoint2d(gs1, gs2); + free(gs1); free(gs2); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + wkt1, wkt2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomDisjoint2dPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomDisjoint2dPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomDisjoint2dPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomDwithin2dPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomDwithin2dPhysicalFunction.cpp new file mode 100644 index 0000000000..47c5446716 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomDwithin2dPhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomDwithin2dPhysicalFunction::GeomDwithin2dPhysicalFunction(PhysicalFunction wkt1Function, + PhysicalFunction wkt2Function, + PhysicalFunction distFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(wkt1Function)); + paramFns.push_back(std::move(wkt2Function)); + paramFns.push_back(std::move(distFunction)); +} + +VarVal GeomDwithin2dPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + auto dist = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz, double d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + bool r = geom_dwithin2d(gs1, gs2, d); + free(gs1); free(gs2); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + wkt1, wkt2, dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomDwithin2dPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "GeomDwithin2dPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return GeomDwithin2dPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomIntersects2dPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomIntersects2dPhysicalFunction.cpp new file mode 100644 index 0000000000..9fc552d4f2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomIntersects2dPhysicalFunction.cpp @@ -0,0 +1,80 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomIntersects2dPhysicalFunction::GeomIntersects2dPhysicalFunction(PhysicalFunction wkt1Function, + PhysicalFunction wkt2Function) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1Function)); + paramFns.push_back(std::move(wkt2Function)); +} + +VarVal GeomIntersects2dPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + bool r = geom_intersects2d(gs1, gs2); + free(gs1); free(gs2); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + wkt1, wkt2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomIntersects2dPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomIntersects2dPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomIntersects2dPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 4ea0dfc476..8fe2bf37b1 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D; sinkClause: INTO sink (',' sink)*; @@ -758,6 +758,10 @@ TTEXT_INITCAP: 'TTEXT_INITCAP' | 'ttext_initcap'; TEXTCAT_TTEXT_TEXT: 'TEXTCAT_TTEXT_TEXT' | 'textcat_ttext_text'; TEXTCAT_TEXT_TTEXT: 'TEXTCAT_TEXT_TTEXT' | 'textcat_text_ttext'; TEXTCAT_TTEXT_TTEXT: 'TEXTCAT_TTEXT_TTEXT' | 'textcat_ttext_ttext'; +GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; +GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; +GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; +GEOM_DISJOINT2D: 'GEOM_DISJOINT2D' | 'geom_disjoint2d'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 3f9dfbfced..0f842ca30f 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -339,6 +339,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -8746,6 +8750,43 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(TextcatTtextTtextLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); } /* END CODEGEN PARSER GLUE: TEXTCAT_TTEXT_TTEXT */ + case AntlrSQLParser::GEOM_INTERSECTS2D: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomIntersects2d requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomIntersects2dLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ + case AntlrSQLParser::GEOM_DWITHIN2D: { + PRECONDITION(ctx->functionParam().size() == 3, + "GeomDwithin2d requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(GeomDwithin2dLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: GEOM_DWITHIN2D */ + case AntlrSQLParser::GEOM_CONTAINS: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomContains requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomContainsLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_CONTAINS */ + case AntlrSQLParser::GEOM_DISJOINT2D: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomDisjoint2d requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomDisjoint2dLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_DISJOINT2D */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From b95c55d00cf281105a027db79bfd9353057837b7 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Sun, 14 Jun 2026 12:05:57 +0200 Subject: [PATCH 47/86] feat(meos): add GEOM_{COVERS,TOUCHES,INTERSECTS3D,DWITHIN3D,DISTANCE2D,DISTANCE3D} NES operators (W98) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wire geom_covers, geom_touches, geom_intersects3d (2-arg: wkt1,wkt2 → float64 0/1), geom_dwithin3d (3-arg: adds dist:float64), geom_distance2d, and geom_distance3d (2-arg: wkt1,wkt2 → float64 actual distance) as per-event scalar NES operators on plain WKT geometry strings. --- .../Meos/GeomCoversLogicalFunction.hpp | 50 +++++++++ .../Meos/GeomDistance2dLogicalFunction.hpp | 50 +++++++++ .../Meos/GeomDistance3dLogicalFunction.hpp | 50 +++++++++ .../Meos/GeomDwithin3dLogicalFunction.hpp | 50 +++++++++ .../Meos/GeomIntersects3dLogicalFunction.hpp | 50 +++++++++ .../Meos/GeomTouchesLogicalFunction.hpp | 50 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../Meos/GeomCoversLogicalFunction.cpp | 101 +++++++++++++++++ .../Meos/GeomDistance2dLogicalFunction.cpp | 101 +++++++++++++++++ .../Meos/GeomDistance3dLogicalFunction.cpp | 101 +++++++++++++++++ .../Meos/GeomDwithin3dLogicalFunction.cpp | 103 ++++++++++++++++++ .../Meos/GeomIntersects3dLogicalFunction.cpp | 101 +++++++++++++++++ .../Meos/GeomTouchesLogicalFunction.cpp | 101 +++++++++++++++++ .../Meos/GeomCoversPhysicalFunction.hpp | 34 ++++++ .../Meos/GeomDistance2dPhysicalFunction.hpp | 34 ++++++ .../Meos/GeomDistance3dPhysicalFunction.hpp | 34 ++++++ .../Meos/GeomDwithin3dPhysicalFunction.hpp | 34 ++++++ .../Meos/GeomIntersects3dPhysicalFunction.hpp | 34 ++++++ .../Meos/GeomTouchesPhysicalFunction.hpp | 34 ++++++ .../src/Functions/Meos/CMakeLists.txt | 6 + .../Meos/GeomCoversPhysicalFunction.cpp | 80 ++++++++++++++ .../Meos/GeomDistance2dPhysicalFunction.cpp | 80 ++++++++++++++ .../Meos/GeomDistance3dPhysicalFunction.cpp | 80 ++++++++++++++ .../Meos/GeomDwithin3dPhysicalFunction.cpp | 84 ++++++++++++++ .../Meos/GeomIntersects3dPhysicalFunction.cpp | 80 ++++++++++++++ .../Meos/GeomTouchesPhysicalFunction.cpp | 80 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 61 +++++++++++ 28 files changed, 1676 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeomCoversLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomDistance2dLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomDistance3dLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomDwithin3dLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomIntersects3dLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomTouchesLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomCoversLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomDistance2dLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomDistance3dLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomDwithin3dLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomIntersects3dLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomTouchesLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomCoversPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomDistance2dPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomDistance3dPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomDwithin3dPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomIntersects3dPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomTouchesPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomCoversPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomDistance2dPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomDistance3dPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomDwithin3dPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomIntersects3dPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomTouchesPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeomCoversLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomCoversLogicalFunction.hpp new file mode 100644 index 0000000000..5b41e8b2ce --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomCoversLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Static geometry function geom_covers: (wkt1:VARCHAR, wkt2:VARCHAR) -> float64 (0/1). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function `geom_covers`. + */ +class GeomCoversLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomCovers"; + + GeomCoversLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomDistance2dLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomDistance2dLogicalFunction.hpp new file mode 100644 index 0000000000..ff67003139 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomDistance2dLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Static geometry function geom_distance2d: (wkt1:VARCHAR, wkt2:VARCHAR) -> float64 distance. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function `geom_distance2d`. + */ +class GeomDistance2dLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomDistance2d"; + + GeomDistance2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomDistance3dLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomDistance3dLogicalFunction.hpp new file mode 100644 index 0000000000..b752f82131 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomDistance3dLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Static geometry function geom_distance3d: (wkt1:VARCHAR, wkt2:VARCHAR) -> float64 distance. + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function `geom_distance3d`. + */ +class GeomDistance3dLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomDistance3d"; + + GeomDistance3dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomDwithin3dLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomDwithin3dLogicalFunction.hpp new file mode 100644 index 0000000000..f135afa6e6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomDwithin3dLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Static geometry function geom_dwithin3d: (wkt1:VARCHAR, wkt2:VARCHAR, dist:FLOAT64) -> float64 (0/1). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function `geom_dwithin3d`. + */ +class GeomDwithin3dLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomDwithin3d"; + + GeomDwithin3dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2, LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomIntersects3dLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomIntersects3dLogicalFunction.hpp new file mode 100644 index 0000000000..9d80a0c50a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomIntersects3dLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Static geometry function geom_intersects3d: (wkt1:VARCHAR, wkt2:VARCHAR) -> float64 (0/1). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function `geom_intersects3d`. + */ +class GeomIntersects3dLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomIntersects3d"; + + GeomIntersects3dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomTouchesLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomTouchesLogicalFunction.hpp new file mode 100644 index 0000000000..a146d450c5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomTouchesLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Static geometry function geom_touches: (wkt1:VARCHAR, wkt2:VARCHAR) -> float64 (0/1). + * + * Generated by tools/codegen/codegen_nebula.py from the MEOS function `geom_touches`. + */ +class GeomTouchesLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomTouches"; + + GeomTouchesLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 2c99730b1c..ed743c292a 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -292,3 +292,9 @@ add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) add_plugin(GeomDisjoint2d LogicalFunction nes-logical-operators GeomDisjoint2dLogicalFunction.cpp) +add_plugin(GeomCovers LogicalFunction nes-logical-operators GeomCoversLogicalFunction.cpp) +add_plugin(GeomTouches LogicalFunction nes-logical-operators GeomTouchesLogicalFunction.cpp) +add_plugin(GeomIntersects3d LogicalFunction nes-logical-operators GeomIntersects3dLogicalFunction.cpp) +add_plugin(GeomDwithin3d LogicalFunction nes-logical-operators GeomDwithin3dLogicalFunction.cpp) +add_plugin(GeomDistance2d LogicalFunction nes-logical-operators GeomDistance2dLogicalFunction.cpp) +add_plugin(GeomDistance3d LogicalFunction nes-logical-operators GeomDistance3dLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeomCoversLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomCoversLogicalFunction.cpp new file mode 100644 index 0000000000..f1f9b565b7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomCoversLogicalFunction.cpp @@ -0,0 +1,101 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomCoversLogicalFunction::GeomCoversLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomCoversLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomCoversLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomCoversLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomCoversLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "GeomCoversLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomCoversLogicalFunction::getType() const { return NAME; } + +bool GeomCoversLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomCoversLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction GeomCoversLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction GeomCoversLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomCoversLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomCoversLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomCoversLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomDistance2dLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomDistance2dLogicalFunction.cpp new file mode 100644 index 0000000000..fc109801a4 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomDistance2dLogicalFunction.cpp @@ -0,0 +1,101 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomDistance2dLogicalFunction::GeomDistance2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomDistance2dLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomDistance2dLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomDistance2dLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomDistance2dLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "GeomDistance2dLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomDistance2dLogicalFunction::getType() const { return NAME; } + +bool GeomDistance2dLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomDistance2dLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction GeomDistance2dLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction GeomDistance2dLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomDistance2dLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomDistance2dLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomDistance2dLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomDistance3dLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomDistance3dLogicalFunction.cpp new file mode 100644 index 0000000000..4aef02ec00 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomDistance3dLogicalFunction.cpp @@ -0,0 +1,101 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomDistance3dLogicalFunction::GeomDistance3dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomDistance3dLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomDistance3dLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomDistance3dLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomDistance3dLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "GeomDistance3dLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomDistance3dLogicalFunction::getType() const { return NAME; } + +bool GeomDistance3dLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomDistance3dLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction GeomDistance3dLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction GeomDistance3dLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomDistance3dLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomDistance3dLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomDistance3dLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomDwithin3dLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomDwithin3dLogicalFunction.cpp new file mode 100644 index 0000000000..8907cea610 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomDwithin3dLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomDwithin3dLogicalFunction::GeomDwithin3dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2, LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); + parameters.push_back(std::move(dist)); +} + +DataType GeomDwithin3dLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomDwithin3dLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomDwithin3dLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomDwithin3dLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, "GeomDwithin3dLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomDwithin3dLogicalFunction::getType() const { return NAME; } + +bool GeomDwithin3dLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomDwithin3dLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction GeomDwithin3dLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction GeomDwithin3dLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomDwithin3dLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "GeomDwithin3dLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return GeomDwithin3dLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomIntersects3dLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomIntersects3dLogicalFunction.cpp new file mode 100644 index 0000000000..bc0ae39b53 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomIntersects3dLogicalFunction.cpp @@ -0,0 +1,101 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomIntersects3dLogicalFunction::GeomIntersects3dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomIntersects3dLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomIntersects3dLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomIntersects3dLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomIntersects3dLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "GeomIntersects3dLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomIntersects3dLogicalFunction::getType() const { return NAME; } + +bool GeomIntersects3dLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomIntersects3dLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction GeomIntersects3dLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction GeomIntersects3dLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomIntersects3dLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomIntersects3dLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomIntersects3dLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomTouchesLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomTouchesLogicalFunction.cpp new file mode 100644 index 0000000000..e8e776a850 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomTouchesLogicalFunction.cpp @@ -0,0 +1,101 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomTouchesLogicalFunction::GeomTouchesLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomTouchesLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomTouchesLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomTouchesLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomTouchesLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "GeomTouchesLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomTouchesLogicalFunction::getType() const { return NAME; } + +bool GeomTouchesLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomTouchesLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + std::string args; + for (size_t index = 0; index < parameters.size(); ++index) { + if (index > 0) args += ", "; + args += parameters[index].explain(verbosity); + } + return fmt::format("{}({})", NAME, args); +} + +LogicalFunction GeomTouchesLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(parameters.size()); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + return withChildren(newChildren); +} + +SerializableFunction GeomTouchesLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomTouchesLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomTouchesLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomTouchesLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomCoversPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomCoversPhysicalFunction.hpp new file mode 100644 index 0000000000..fc4766e34e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomCoversPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomCoversPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomCoversPhysicalFunction(PhysicalFunction wkt1Function, PhysicalFunction wkt2Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomDistance2dPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomDistance2dPhysicalFunction.hpp new file mode 100644 index 0000000000..139d856a64 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomDistance2dPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomDistance2dPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomDistance2dPhysicalFunction(PhysicalFunction wkt1Function, PhysicalFunction wkt2Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomDistance3dPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomDistance3dPhysicalFunction.hpp new file mode 100644 index 0000000000..1e609d2cf7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomDistance3dPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomDistance3dPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomDistance3dPhysicalFunction(PhysicalFunction wkt1Function, PhysicalFunction wkt2Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomDwithin3dPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomDwithin3dPhysicalFunction.hpp new file mode 100644 index 0000000000..4e895d8a95 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomDwithin3dPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomDwithin3dPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomDwithin3dPhysicalFunction(PhysicalFunction wkt1Function, PhysicalFunction wkt2Function, PhysicalFunction distFunction); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomIntersects3dPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomIntersects3dPhysicalFunction.hpp new file mode 100644 index 0000000000..fc27c5635e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomIntersects3dPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomIntersects3dPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomIntersects3dPhysicalFunction(PhysicalFunction wkt1Function, PhysicalFunction wkt2Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomTouchesPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomTouchesPhysicalFunction.hpp new file mode 100644 index 0000000000..9fac03a277 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomTouchesPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomTouchesPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomTouchesPhysicalFunction(PhysicalFunction wkt1Function, PhysicalFunction wkt2Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 4701e0568c..a9ac96980e 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -291,4 +291,10 @@ add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersec add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) add_plugin(GeomDisjoint2d PhysicalFunction nes-physical-operators GeomDisjoint2dPhysicalFunction.cpp) +add_plugin(GeomCovers PhysicalFunction nes-physical-operators GeomCoversPhysicalFunction.cpp) +add_plugin(GeomTouches PhysicalFunction nes-physical-operators GeomTouchesPhysicalFunction.cpp) +add_plugin(GeomIntersects3d PhysicalFunction nes-physical-operators GeomIntersects3dPhysicalFunction.cpp) +add_plugin(GeomDwithin3d PhysicalFunction nes-physical-operators GeomDwithin3dPhysicalFunction.cpp) +add_plugin(GeomDistance2d PhysicalFunction nes-physical-operators GeomDistance2dPhysicalFunction.cpp) +add_plugin(GeomDistance3d PhysicalFunction nes-physical-operators GeomDistance3dPhysicalFunction.cpp) endif() diff --git a/nes-physical-operators/src/Functions/Meos/GeomCoversPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomCoversPhysicalFunction.cpp new file mode 100644 index 0000000000..c757aa9fb8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomCoversPhysicalFunction.cpp @@ -0,0 +1,80 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomCoversPhysicalFunction::GeomCoversPhysicalFunction(PhysicalFunction wkt1Function, + PhysicalFunction wkt2Function) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1Function)); + paramFns.push_back(std::move(wkt2Function)); +} + +VarVal GeomCoversPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + bool r = geom_covers(gs1, gs2); + free(gs1); free(gs2); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + wkt1, wkt2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomCoversPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomCoversPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomCoversPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomDistance2dPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomDistance2dPhysicalFunction.cpp new file mode 100644 index 0000000000..9a29adab1c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomDistance2dPhysicalFunction.cpp @@ -0,0 +1,80 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomDistance2dPhysicalFunction::GeomDistance2dPhysicalFunction(PhysicalFunction wkt1Function, + PhysicalFunction wkt2Function) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1Function)); + paramFns.push_back(std::move(wkt2Function)); +} + +VarVal GeomDistance2dPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + double r = geom_distance2d(gs1, gs2); + free(gs1); free(gs2); + return r; + } catch (const std::exception&) { return 0.0; } + }, + wkt1, wkt2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomDistance2dPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomDistance2dPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomDistance2dPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomDistance3dPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomDistance3dPhysicalFunction.cpp new file mode 100644 index 0000000000..05c7667dce --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomDistance3dPhysicalFunction.cpp @@ -0,0 +1,80 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomDistance3dPhysicalFunction::GeomDistance3dPhysicalFunction(PhysicalFunction wkt1Function, + PhysicalFunction wkt2Function) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1Function)); + paramFns.push_back(std::move(wkt2Function)); +} + +VarVal GeomDistance3dPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + double r = geom_distance3d(gs1, gs2); + free(gs1); free(gs2); + return r; + } catch (const std::exception&) { return 0.0; } + }, + wkt1, wkt2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomDistance3dPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomDistance3dPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomDistance3dPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomDwithin3dPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomDwithin3dPhysicalFunction.cpp new file mode 100644 index 0000000000..429b558521 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomDwithin3dPhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomDwithin3dPhysicalFunction::GeomDwithin3dPhysicalFunction(PhysicalFunction wkt1Function, + PhysicalFunction wkt2Function, + PhysicalFunction distFunction) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(wkt1Function)); + paramFns.push_back(std::move(wkt2Function)); + paramFns.push_back(std::move(distFunction)); +} + +VarVal GeomDwithin3dPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + auto dist = paramFns[2].execute(record, arena).cast>(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz, double d) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + bool r = geom_dwithin3d(gs1, gs2, d); + free(gs1); free(gs2); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + wkt1, wkt2, dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomDwithin3dPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "GeomDwithin3dPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return GeomDwithin3dPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomIntersects3dPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomIntersects3dPhysicalFunction.cpp new file mode 100644 index 0000000000..cbd4e019c2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomIntersects3dPhysicalFunction.cpp @@ -0,0 +1,80 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomIntersects3dPhysicalFunction::GeomIntersects3dPhysicalFunction(PhysicalFunction wkt1Function, + PhysicalFunction wkt2Function) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1Function)); + paramFns.push_back(std::move(wkt2Function)); +} + +VarVal GeomIntersects3dPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + bool r = geom_intersects3d(gs1, gs2); + free(gs1); free(gs2); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + wkt1, wkt2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomIntersects3dPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomIntersects3dPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomIntersects3dPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomTouchesPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomTouchesPhysicalFunction.cpp new file mode 100644 index 0000000000..8df0beaafe --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomTouchesPhysicalFunction.cpp @@ -0,0 +1,80 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomTouchesPhysicalFunction::GeomTouchesPhysicalFunction(PhysicalFunction wkt1Function, + PhysicalFunction wkt2Function) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1Function)); + paramFns.push_back(std::move(wkt2Function)); +} + +VarVal GeomTouchesPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + bool r = geom_touches(gs1, gs2); + free(gs1); free(gs2); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + wkt1, wkt2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomTouchesPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomTouchesPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomTouchesPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 8fe2bf37b1..102f28fdbb 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -762,6 +762,12 @@ GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; GEOM_DISJOINT2D: 'GEOM_DISJOINT2D' | 'geom_disjoint2d'; +GEOM_COVERS: 'GEOM_COVERS' | 'geom_covers'; +GEOM_TOUCHES: 'GEOM_TOUCHES' | 'geom_touches'; +GEOM_INTERSECTS3D: 'GEOM_INTERSECTS3D' | 'geom_intersects3d'; +GEOM_DWITHIN3D: 'GEOM_DWITHIN3D' | 'geom_dwithin3d'; +GEOM_DISTANCE2D: 'GEOM_DISTANCE2D' | 'geom_distance2d'; +GEOM_DISTANCE3D: 'GEOM_DISTANCE3D' | 'geom_distance3d'; WATERMARK: 'WATERMARK' | 'watermark'; OFFSET: 'OFFSET' | 'offset'; LOCALHOST: 'LOCALHOST' | 'localhost'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 0f842ca30f..70f8755af2 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -343,6 +343,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -8787,6 +8793,61 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(GeomDisjoint2dLogicalFunction(std::move(arg0), std::move(arg1))); } /* END CODEGEN PARSER GLUE: GEOM_DISJOINT2D */ + case AntlrSQLParser::GEOM_COVERS: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomCovers requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomCoversLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_COVERS */ + case AntlrSQLParser::GEOM_TOUCHES: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomTouches requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomTouchesLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_TOUCHES */ + case AntlrSQLParser::GEOM_INTERSECTS3D: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomIntersects3d requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomIntersects3dLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS3D */ + case AntlrSQLParser::GEOM_DWITHIN3D: { + PRECONDITION(ctx->functionParam().size() == 3, + "GeomDwithin3d requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(GeomDwithin3dLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: GEOM_DWITHIN3D */ + case AntlrSQLParser::GEOM_DISTANCE2D: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomDistance2d requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomDistance2dLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_DISTANCE2D */ + case AntlrSQLParser::GEOM_DISTANCE3D: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomDistance3d requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomDistance3dLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_DISTANCE3D */ /* BEGIN CODEGEN PARSER GLUE: ALWAYS_EQ_TFLOAT_FLOAT */ case AntlrSQLLexer::ALWAYS_EQ_TFLOAT_FLOAT: { From 5814c34df2cd203a47ef7ae6c92eb713b3909194 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Sun, 14 Jun 2026 12:16:37 +0200 Subject: [PATCH 48/86] feat(meos): add GEOM_{LENGTH,PERIMETER} NES operators (W99) --- .../Meos/GeomLengthLogicalFunction.hpp | 51 ++++++++++ .../Meos/GeomPerimeterLogicalFunction.hpp | 51 ++++++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../Meos/GeomLengthLogicalFunction.cpp | 94 +++++++++++++++++++ .../Meos/GeomPerimeterLogicalFunction.cpp | 94 +++++++++++++++++++ .../Meos/GeomLengthPhysicalFunction.hpp | 34 +++++++ .../Meos/GeomPerimeterPhysicalFunction.hpp | 34 +++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../Meos/GeomLengthPhysicalFunction.cpp | 73 ++++++++++++++ .../Meos/GeomPerimeterPhysicalFunction.cpp | 73 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 4 +- .../src/AntlrSQLQueryPlanCreator.cpp | 18 ++++ 12 files changed, 529 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeomLengthLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomPerimeterLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomLengthLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomPerimeterLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomLengthPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomPerimeterPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomLengthPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomPerimeterPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeomLengthLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomLengthLogicalFunction.hpp new file mode 100644 index 0000000000..5de9ddc37b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomLengthLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Static geometry scalar geom_length: (wkt1:VARCHAR) -> float64. + * + * Generated from the MEOS function `geom_length`. + * Operates on plain WKT strings without a temporal dimension. + */ +class GeomLengthLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomLength"; + + explicit GeomLengthLogicalFunction(LogicalFunction wkt1); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomPerimeterLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomPerimeterLogicalFunction.hpp new file mode 100644 index 0000000000..a9b82a52a0 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomPerimeterLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Static geometry scalar geom_perimeter: (wkt1:VARCHAR) -> float64. + * + * Generated from the MEOS function `geom_perimeter`. + * Operates on plain WKT strings without a temporal dimension. + */ +class GeomPerimeterLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomPerimeter"; + + explicit GeomPerimeterLogicalFunction(LogicalFunction wkt1); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index ed743c292a..6797e5790c 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -288,6 +288,8 @@ add_plugin(TtextInitcap LogicalFunction nes-logical-operators TtextInitcapLogica add_plugin(TextcatTtextText LogicalFunction nes-logical-operators TextcatTtextTextLogicalFunction.cpp) add_plugin(TextcatTextTtext LogicalFunction nes-logical-operators TextcatTextTtextLogicalFunction.cpp) add_plugin(TextcatTtextTtext LogicalFunction nes-logical-operators TextcatTtextTtextLogicalFunction.cpp) +add_plugin(GeomLength LogicalFunction nes-logical-operators GeomLengthLogicalFunction.cpp) +add_plugin(GeomPerimeter LogicalFunction nes-logical-operators GeomPerimeterLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeomLengthLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomLengthLogicalFunction.cpp new file mode 100644 index 0000000000..c86f9b001b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomLengthLogicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomLengthLogicalFunction::GeomLengthLogicalFunction(LogicalFunction wkt1) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt1)); +} + +DataType GeomLengthLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomLengthLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomLengthLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomLengthLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, "GeomLengthLogicalFunction requires 1 child, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomLengthLogicalFunction::getType() const { return NAME; } + +bool GeomLengthLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomLengthLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomLengthLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(1); + newChildren.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(newChildren[0].getDataType().isType(DataType::Type::VARSIZED), + "wkt1 must be VARSIZED, but was: {}", newChildren[0].getDataType()); + return withChildren(newChildren); +} + +SerializableFunction GeomLengthLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomLengthLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeomLengthLogicalFunction requires 1 child but got {}", + arguments.children.size()); + return GeomLengthLogicalFunction(std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomPerimeterLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomPerimeterLogicalFunction.cpp new file mode 100644 index 0000000000..1b5b36c4cc --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomPerimeterLogicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomPerimeterLogicalFunction::GeomPerimeterLogicalFunction(LogicalFunction wkt1) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt1)); +} + +DataType GeomPerimeterLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomPerimeterLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomPerimeterLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomPerimeterLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, "GeomPerimeterLogicalFunction requires 1 child, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomPerimeterLogicalFunction::getType() const { return NAME; } + +bool GeomPerimeterLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomPerimeterLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomPerimeterLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(1); + newChildren.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(newChildren[0].getDataType().isType(DataType::Type::VARSIZED), + "wkt1 must be VARSIZED, but was: {}", newChildren[0].getDataType()); + return withChildren(newChildren); +} + +SerializableFunction GeomPerimeterLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomPerimeterLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeomPerimeterLogicalFunction requires 1 child but got {}", + arguments.children.size()); + return GeomPerimeterLogicalFunction(std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomLengthPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomLengthPhysicalFunction.hpp new file mode 100644 index 0000000000..d7aced0440 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomLengthPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomLengthPhysicalFunction : public PhysicalFunctionConcept { +public: + explicit GeomLengthPhysicalFunction(PhysicalFunction wkt1Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomPerimeterPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomPerimeterPhysicalFunction.hpp new file mode 100644 index 0000000000..281310c367 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomPerimeterPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomPerimeterPhysicalFunction : public PhysicalFunctionConcept { +public: + explicit GeomPerimeterPhysicalFunction(PhysicalFunction wkt1Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index a9ac96980e..3c6c8d2539 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -287,6 +287,8 @@ add_plugin(TtextInitcap PhysicalFunction nes-physical-operators TtextInitcapPhys add_plugin(TextcatTtextText PhysicalFunction nes-physical-operators TextcatTtextTextPhysicalFunction.cpp) add_plugin(TextcatTextTtext PhysicalFunction nes-physical-operators TextcatTextTtextPhysicalFunction.cpp) add_plugin(TextcatTtextTtext PhysicalFunction nes-physical-operators TextcatTtextTtextPhysicalFunction.cpp) +add_plugin(GeomLength PhysicalFunction nes-physical-operators GeomLengthPhysicalFunction.cpp) +add_plugin(GeomPerimeter PhysicalFunction nes-physical-operators GeomPerimeterPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/GeomLengthPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomLengthPhysicalFunction.cpp new file mode 100644 index 0000000000..79ac73c676 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomLengthPhysicalFunction.cpp @@ -0,0 +1,73 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomLengthPhysicalFunction::GeomLengthPhysicalFunction(PhysicalFunction wkt1Function) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt1Function)); +} + +VarVal GeomLengthPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + double r = geom_length(gs1); + free(gs1); + return r; + } catch (const std::exception&) { return 0.0; } + }, + wkt1); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomLengthPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeomLengthPhysicalFunction requires 1 child but got {}", + arguments.childFunctions.size()); + return GeomLengthPhysicalFunction(std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomPerimeterPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomPerimeterPhysicalFunction.cpp new file mode 100644 index 0000000000..7e56e10181 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomPerimeterPhysicalFunction.cpp @@ -0,0 +1,73 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomPerimeterPhysicalFunction::GeomPerimeterPhysicalFunction(PhysicalFunction wkt1Function) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt1Function)); +} + +VarVal GeomPerimeterPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + double r = geom_perimeter(gs1); + free(gs1); + return r; + } catch (const std::exception&) { return 0.0; } + }, + wkt1); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomPerimeterPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeomPerimeterPhysicalFunction requires 1 child but got {}", + arguments.childFunctions.size()); + return GeomPerimeterPhysicalFunction(std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 102f28fdbb..2671e33d6f 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -758,6 +758,8 @@ TTEXT_INITCAP: 'TTEXT_INITCAP' | 'ttext_initcap'; TEXTCAT_TTEXT_TEXT: 'TEXTCAT_TTEXT_TEXT' | 'textcat_ttext_text'; TEXTCAT_TEXT_TTEXT: 'TEXTCAT_TEXT_TTEXT' | 'textcat_text_ttext'; TEXTCAT_TTEXT_TTEXT: 'TEXTCAT_TTEXT_TTEXT' | 'textcat_ttext_ttext'; +GEOM_LENGTH: 'GEOM_LENGTH' | 'geom_length'; +GEOM_PERIMETER: 'GEOM_PERIMETER' | 'geom_perimeter'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 70f8755af2..7cbcfdabe7 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -339,6 +339,8 @@ #include #include #include +#include +#include #include #include #include @@ -8764,6 +8766,22 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont auto arg1 = visit(ctx->functionParam(1)).as(); return LogicalFunction(GeomIntersects2dLogicalFunction(std::move(arg0), std::move(arg1))); } + case AntlrSQLParser::GEOM_LENGTH: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeomLength requires 1 arg but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeomLengthLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOM_LENGTH */ + case AntlrSQLParser::GEOM_PERIMETER: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeomPerimeter requires 1 arg but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeomPerimeterLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOM_PERIMETER */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From eb4407cf3eb07fe739377961bba528d749b0d174 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Sun, 14 Jun 2026 12:24:38 +0200 Subject: [PATCH 49/86] feat(meos): add GEOM_AZIMUTH NES operator (W101) --- .../Meos/GeomAzimuthLogicalFunction.hpp | 52 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 1 + .../Meos/GeomAzimuthLogicalFunction.cpp | 101 ++++++++++++++++++ .../Meos/GeomAzimuthPhysicalFunction.hpp | 34 ++++++ .../src/Functions/Meos/CMakeLists.txt | 1 + .../Meos/GeomAzimuthPhysicalFunction.cpp | 80 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 3 +- .../src/AntlrSQLQueryPlanCreator.cpp | 10 ++ 8 files changed, 281 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeomAzimuthLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomAzimuthLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomAzimuthPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomAzimuthPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeomAzimuthLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomAzimuthLogicalFunction.hpp new file mode 100644 index 0000000000..bf5f526490 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomAzimuthLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Static geometry azimuth geom_azimuth: (wkt1:VARCHAR, wkt2:VARCHAR) -> float64 (radians). + * + * Generated from the MEOS function `geom_azimuth`. + * Returns the azimuth angle from the first point to the second, in radians; + * returns 0.0 when the azimuth is undefined (identical points). + */ +class GeomAzimuthLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomAzimuth"; + + GeomAzimuthLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 6797e5790c..2f05cb64c8 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -290,6 +290,7 @@ add_plugin(TextcatTextTtext LogicalFunction nes-logical-operators TextcatTextTte add_plugin(TextcatTtextTtext LogicalFunction nes-logical-operators TextcatTtextTtextLogicalFunction.cpp) add_plugin(GeomLength LogicalFunction nes-logical-operators GeomLengthLogicalFunction.cpp) add_plugin(GeomPerimeter LogicalFunction nes-logical-operators GeomPerimeterLogicalFunction.cpp) +add_plugin(GeomAzimuth LogicalFunction nes-logical-operators GeomAzimuthLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeomAzimuthLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomAzimuthLogicalFunction.cpp new file mode 100644 index 0000000000..b3d52556c5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomAzimuthLogicalFunction.cpp @@ -0,0 +1,101 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomAzimuthLogicalFunction::GeomAzimuthLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomAzimuthLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomAzimuthLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomAzimuthLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomAzimuthLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, "GeomAzimuthLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomAzimuthLogicalFunction::getType() const { return NAME; } + +bool GeomAzimuthLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomAzimuthLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({}, {})", NAME, + parameters[0].explain(verbosity), + parameters[1].explain(verbosity)); +} + +LogicalFunction GeomAzimuthLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(2); + for (const auto& child : parameters) + newChildren.emplace_back(child.withInferredDataType(schema)); + INVARIANT(newChildren[0].getDataType().isType(DataType::Type::VARSIZED), + "wkt1 must be VARSIZED, but was: {}", newChildren[0].getDataType()); + INVARIANT(newChildren[1].getDataType().isType(DataType::Type::VARSIZED), + "wkt2 must be VARSIZED, but was: {}", newChildren[1].getDataType()); + return withChildren(newChildren); +} + +SerializableFunction GeomAzimuthLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomAzimuthLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomAzimuthLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomAzimuthLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomAzimuthPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomAzimuthPhysicalFunction.hpp new file mode 100644 index 0000000000..fc38a19987 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomAzimuthPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomAzimuthPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomAzimuthPhysicalFunction(PhysicalFunction wkt1Function, PhysicalFunction wkt2Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 3c6c8d2539..2d048b3207 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -289,6 +289,7 @@ add_plugin(TextcatTextTtext PhysicalFunction nes-physical-operators TextcatTextT add_plugin(TextcatTtextTtext PhysicalFunction nes-physical-operators TextcatTtextTtextPhysicalFunction.cpp) add_plugin(GeomLength PhysicalFunction nes-physical-operators GeomLengthPhysicalFunction.cpp) add_plugin(GeomPerimeter PhysicalFunction nes-physical-operators GeomPerimeterPhysicalFunction.cpp) +add_plugin(GeomAzimuth PhysicalFunction nes-physical-operators GeomAzimuthPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/GeomAzimuthPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomAzimuthPhysicalFunction.cpp new file mode 100644 index 0000000000..bb301910ba --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomAzimuthPhysicalFunction.cpp @@ -0,0 +1,80 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomAzimuthPhysicalFunction::GeomAzimuthPhysicalFunction(PhysicalFunction wkt1Function, + PhysicalFunction wkt2Function) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1Function)); + paramFns.push_back(std::move(wkt2Function)); +} + +VarVal GeomAzimuthPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + double azimuth = 0.0; + geom_azimuth(gs1, gs2, &azimuth); + free(gs1); free(gs2); + return azimuth; + } catch (const std::exception&) { return 0.0; } + }, + wkt1, wkt2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomAzimuthPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomAzimuthPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomAzimuthPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 2671e33d6f..19fc5b0913 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -760,6 +760,7 @@ TEXTCAT_TEXT_TTEXT: 'TEXTCAT_TEXT_TTEXT' | 'textcat_text_ttext'; TEXTCAT_TTEXT_TTEXT: 'TEXTCAT_TTEXT_TTEXT' | 'textcat_ttext_ttext'; GEOM_LENGTH: 'GEOM_LENGTH' | 'geom_length'; GEOM_PERIMETER: 'GEOM_PERIMETER' | 'geom_perimeter'; +GEOM_AZIMUTH: 'GEOM_AZIMUTH' | 'geom_azimuth'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 7cbcfdabe7..09ae3962b7 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -341,6 +341,7 @@ #include #include #include +#include #include #include #include @@ -8782,6 +8783,15 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(GeomPerimeterLogicalFunction(std::move(arg0))); } /* END CODEGEN PARSER GLUE: GEOM_PERIMETER */ + case AntlrSQLParser::GEOM_AZIMUTH: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomAzimuth requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomAzimuthLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_AZIMUTH */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 8e389bcfb551804dbb8497b4e4c284e9616b9b2d Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Sun, 14 Jun 2026 15:41:07 +0200 Subject: [PATCH 50/86] feat(meos): add GEOG_{AREA,LENGTH,PERIMETER} and GEOM_IS_EMPTY NES operators (W102) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wire four geographic/geometry scalar operators via the MEOS API: GEOG_AREA, GEOG_LENGTH, GEOG_PERIMETER (geog_area/geog_length/geog_perimeter, use_spheroid=true) and GEOM_IS_EMPTY (geo_is_empty → 0.0/1.0). All take one VARCHAR (WKT) input and return FLOAT64. --- .../Meos/GeogAreaLogicalFunction.hpp | 48 ++++++++++ .../Meos/GeogLengthLogicalFunction.hpp | 48 ++++++++++ .../Meos/GeogPerimeterLogicalFunction.hpp | 48 ++++++++++ .../Meos/GeomIsEmptyLogicalFunction.hpp | 48 ++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/GeogAreaLogicalFunction.cpp | 94 +++++++++++++++++++ .../Meos/GeogLengthLogicalFunction.cpp | 94 +++++++++++++++++++ .../Meos/GeogPerimeterLogicalFunction.cpp | 94 +++++++++++++++++++ .../Meos/GeomIsEmptyLogicalFunction.cpp | 94 +++++++++++++++++++ .../Meos/GeogAreaPhysicalFunction.hpp | 34 +++++++ .../Meos/GeogLengthPhysicalFunction.hpp | 34 +++++++ .../Meos/GeogPerimeterPhysicalFunction.hpp | 34 +++++++ .../Meos/GeomIsEmptyPhysicalFunction.hpp | 34 +++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/GeogAreaPhysicalFunction.cpp | 73 ++++++++++++++ .../Meos/GeogLengthPhysicalFunction.cpp | 73 ++++++++++++++ .../Meos/GeogPerimeterPhysicalFunction.cpp | 73 ++++++++++++++ .../Meos/GeomIsEmptyPhysicalFunction.cpp | 73 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 36 +++++++ 20 files changed, 1045 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeogAreaLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeogLengthLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeogPerimeterLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomIsEmptyLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeogAreaLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeogLengthLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeogPerimeterLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomIsEmptyLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeogAreaPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeogLengthPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeogPerimeterPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomIsEmptyPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeogAreaPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeogLengthPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeogPerimeterPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomIsEmptyPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeogAreaLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeogAreaLogicalFunction.hpp new file mode 100644 index 0000000000..86ec6bfcca --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeogAreaLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Geographic area (spheroid=true) of the geometry: (wkt:VARCHAR) -> float64. + */ +class GeogAreaLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeogArea"; + + explicit GeogAreaLogicalFunction(LogicalFunction wkt1); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeogLengthLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeogLengthLogicalFunction.hpp new file mode 100644 index 0000000000..fc6b2daee4 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeogLengthLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Geographic length (spheroid=true) of the geometry: (wkt:VARCHAR) -> float64. + */ +class GeogLengthLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeogLength"; + + explicit GeogLengthLogicalFunction(LogicalFunction wkt1); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeogPerimeterLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeogPerimeterLogicalFunction.hpp new file mode 100644 index 0000000000..d4a77d61cd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeogPerimeterLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Geographic perimeter (spheroid=true) of the geometry: (wkt:VARCHAR) -> float64. + */ +class GeogPerimeterLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeogPerimeter"; + + explicit GeogPerimeterLogicalFunction(LogicalFunction wkt1); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomIsEmptyLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomIsEmptyLogicalFunction.hpp new file mode 100644 index 0000000000..04bd90a2b3 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomIsEmptyLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the geometry is empty, 0.0 otherwise: (wkt:VARCHAR) -> float64. + */ +class GeomIsEmptyLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomIsEmpty"; + + explicit GeomIsEmptyLogicalFunction(LogicalFunction wkt1); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 2f05cb64c8..47c5aa5c9c 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -291,6 +291,10 @@ add_plugin(TextcatTtextTtext LogicalFunction nes-logical-operators TextcatTtextT add_plugin(GeomLength LogicalFunction nes-logical-operators GeomLengthLogicalFunction.cpp) add_plugin(GeomPerimeter LogicalFunction nes-logical-operators GeomPerimeterLogicalFunction.cpp) add_plugin(GeomAzimuth LogicalFunction nes-logical-operators GeomAzimuthLogicalFunction.cpp) +add_plugin(GeogArea LogicalFunction nes-logical-operators GeogAreaLogicalFunction.cpp) +add_plugin(GeogLength LogicalFunction nes-logical-operators GeogLengthLogicalFunction.cpp) +add_plugin(GeogPerimeter LogicalFunction nes-logical-operators GeogPerimeterLogicalFunction.cpp) +add_plugin(GeomIsEmpty LogicalFunction nes-logical-operators GeomIsEmptyLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeogAreaLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeogAreaLogicalFunction.cpp new file mode 100644 index 0000000000..3e0ff84ffb --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeogAreaLogicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeogAreaLogicalFunction::GeogAreaLogicalFunction(LogicalFunction wkt1) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt1)); +} + +DataType GeogAreaLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeogAreaLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeogAreaLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeogAreaLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, "GeogAreaLogicalFunction requires 1 child, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeogAreaLogicalFunction::getType() const { return NAME; } + +bool GeogAreaLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeogAreaLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeogAreaLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(1); + newChildren.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(newChildren[0].getDataType().isType(DataType::Type::VARSIZED), + "wkt1 must be VARSIZED, but was: {}", newChildren[0].getDataType()); + return withChildren(newChildren); +} + +SerializableFunction GeogAreaLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeogAreaLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeogAreaLogicalFunction requires 1 child but got {}", + arguments.children.size()); + return GeogAreaLogicalFunction(std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeogLengthLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeogLengthLogicalFunction.cpp new file mode 100644 index 0000000000..cda79e46a3 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeogLengthLogicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeogLengthLogicalFunction::GeogLengthLogicalFunction(LogicalFunction wkt1) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt1)); +} + +DataType GeogLengthLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeogLengthLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeogLengthLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeogLengthLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, "GeogLengthLogicalFunction requires 1 child, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeogLengthLogicalFunction::getType() const { return NAME; } + +bool GeogLengthLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeogLengthLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeogLengthLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(1); + newChildren.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(newChildren[0].getDataType().isType(DataType::Type::VARSIZED), + "wkt1 must be VARSIZED, but was: {}", newChildren[0].getDataType()); + return withChildren(newChildren); +} + +SerializableFunction GeogLengthLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeogLengthLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeogLengthLogicalFunction requires 1 child but got {}", + arguments.children.size()); + return GeogLengthLogicalFunction(std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeogPerimeterLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeogPerimeterLogicalFunction.cpp new file mode 100644 index 0000000000..b31424e807 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeogPerimeterLogicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeogPerimeterLogicalFunction::GeogPerimeterLogicalFunction(LogicalFunction wkt1) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt1)); +} + +DataType GeogPerimeterLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeogPerimeterLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeogPerimeterLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeogPerimeterLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, "GeogPerimeterLogicalFunction requires 1 child, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeogPerimeterLogicalFunction::getType() const { return NAME; } + +bool GeogPerimeterLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeogPerimeterLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeogPerimeterLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(1); + newChildren.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(newChildren[0].getDataType().isType(DataType::Type::VARSIZED), + "wkt1 must be VARSIZED, but was: {}", newChildren[0].getDataType()); + return withChildren(newChildren); +} + +SerializableFunction GeogPerimeterLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeogPerimeterLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeogPerimeterLogicalFunction requires 1 child but got {}", + arguments.children.size()); + return GeogPerimeterLogicalFunction(std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomIsEmptyLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomIsEmptyLogicalFunction.cpp new file mode 100644 index 0000000000..bb4232bbc5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomIsEmptyLogicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomIsEmptyLogicalFunction::GeomIsEmptyLogicalFunction(LogicalFunction wkt1) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt1)); +} + +DataType GeomIsEmptyLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomIsEmptyLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomIsEmptyLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomIsEmptyLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, "GeomIsEmptyLogicalFunction requires 1 child, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomIsEmptyLogicalFunction::getType() const { return NAME; } + +bool GeomIsEmptyLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomIsEmptyLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomIsEmptyLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector newChildren; + newChildren.reserve(1); + newChildren.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(newChildren[0].getDataType().isType(DataType::Type::VARSIZED), + "wkt1 must be VARSIZED, but was: {}", newChildren[0].getDataType()); + return withChildren(newChildren); +} + +SerializableFunction GeomIsEmptyLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomIsEmptyLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeomIsEmptyLogicalFunction requires 1 child but got {}", + arguments.children.size()); + return GeomIsEmptyLogicalFunction(std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeogAreaPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeogAreaPhysicalFunction.hpp new file mode 100644 index 0000000000..65ffccf01d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeogAreaPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeogAreaPhysicalFunction : public PhysicalFunctionConcept { +public: + explicit GeogAreaPhysicalFunction(PhysicalFunction wkt1Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeogLengthPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeogLengthPhysicalFunction.hpp new file mode 100644 index 0000000000..281637b5da --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeogLengthPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeogLengthPhysicalFunction : public PhysicalFunctionConcept { +public: + explicit GeogLengthPhysicalFunction(PhysicalFunction wkt1Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeogPerimeterPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeogPerimeterPhysicalFunction.hpp new file mode 100644 index 0000000000..589296f949 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeogPerimeterPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeogPerimeterPhysicalFunction : public PhysicalFunctionConcept { +public: + explicit GeogPerimeterPhysicalFunction(PhysicalFunction wkt1Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomIsEmptyPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomIsEmptyPhysicalFunction.hpp new file mode 100644 index 0000000000..c007fb1000 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomIsEmptyPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomIsEmptyPhysicalFunction : public PhysicalFunctionConcept { +public: + explicit GeomIsEmptyPhysicalFunction(PhysicalFunction wkt1Function); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 2d048b3207..ee1cd1b7c4 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -290,6 +290,10 @@ add_plugin(TextcatTtextTtext PhysicalFunction nes-physical-operators TextcatTtex add_plugin(GeomLength PhysicalFunction nes-physical-operators GeomLengthPhysicalFunction.cpp) add_plugin(GeomPerimeter PhysicalFunction nes-physical-operators GeomPerimeterPhysicalFunction.cpp) add_plugin(GeomAzimuth PhysicalFunction nes-physical-operators GeomAzimuthPhysicalFunction.cpp) +add_plugin(GeogArea PhysicalFunction nes-physical-operators GeogAreaPhysicalFunction.cpp) +add_plugin(GeogLength PhysicalFunction nes-physical-operators GeogLengthPhysicalFunction.cpp) +add_plugin(GeogPerimeter PhysicalFunction nes-physical-operators GeogPerimeterPhysicalFunction.cpp) +add_plugin(GeomIsEmpty PhysicalFunction nes-physical-operators GeomIsEmptyPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/GeogAreaPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeogAreaPhysicalFunction.cpp new file mode 100644 index 0000000000..1d0da3f9a4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeogAreaPhysicalFunction.cpp @@ -0,0 +1,73 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeogAreaPhysicalFunction::GeogAreaPhysicalFunction(PhysicalFunction wkt1Function) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt1Function)); +} + +VarVal GeogAreaPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + double r = geog_area(gs1, true); + free(gs1); + return r; + } catch (const std::exception&) { return 0.0; } + }, + wkt1); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeogAreaPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeogAreaPhysicalFunction requires 1 child but got {}", + arguments.childFunctions.size()); + return GeogAreaPhysicalFunction(std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeogLengthPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeogLengthPhysicalFunction.cpp new file mode 100644 index 0000000000..0e6c8e3e2a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeogLengthPhysicalFunction.cpp @@ -0,0 +1,73 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeogLengthPhysicalFunction::GeogLengthPhysicalFunction(PhysicalFunction wkt1Function) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt1Function)); +} + +VarVal GeogLengthPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + double r = geog_length(gs1, true); + free(gs1); + return r; + } catch (const std::exception&) { return 0.0; } + }, + wkt1); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeogLengthPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeogLengthPhysicalFunction requires 1 child but got {}", + arguments.childFunctions.size()); + return GeogLengthPhysicalFunction(std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeogPerimeterPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeogPerimeterPhysicalFunction.cpp new file mode 100644 index 0000000000..dca1cd8972 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeogPerimeterPhysicalFunction.cpp @@ -0,0 +1,73 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeogPerimeterPhysicalFunction::GeogPerimeterPhysicalFunction(PhysicalFunction wkt1Function) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt1Function)); +} + +VarVal GeogPerimeterPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + double r = geog_perimeter(gs1, true); + free(gs1); + return r; + } catch (const std::exception&) { return 0.0; } + }, + wkt1); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeogPerimeterPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeogPerimeterPhysicalFunction requires 1 child but got {}", + arguments.childFunctions.size()); + return GeogPerimeterPhysicalFunction(std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomIsEmptyPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomIsEmptyPhysicalFunction.cpp new file mode 100644 index 0000000000..cfca0f65e0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomIsEmptyPhysicalFunction.cpp @@ -0,0 +1,73 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomIsEmptyPhysicalFunction::GeomIsEmptyPhysicalFunction(PhysicalFunction wkt1Function) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt1Function)); +} + +VarVal GeomIsEmptyPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + double r = geo_is_empty(gs1) ? 1.0 : 0.0; + free(gs1); + return r; + } catch (const std::exception&) { return 0.0; } + }, + wkt1); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomIsEmptyPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeomIsEmptyPhysicalFunction requires 1 child but got {}", + arguments.childFunctions.size()); + return GeomIsEmptyPhysicalFunction(std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 19fc5b0913..ded03b8e29 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -761,6 +761,10 @@ TEXTCAT_TTEXT_TTEXT: 'TEXTCAT_TTEXT_TTEXT' | 'textcat_ttext_ttext'; GEOM_LENGTH: 'GEOM_LENGTH' | 'geom_length'; GEOM_PERIMETER: 'GEOM_PERIMETER' | 'geom_perimeter'; GEOM_AZIMUTH: 'GEOM_AZIMUTH' | 'geom_azimuth'; +GEOG_AREA: 'GEOG_AREA' | 'geog_area'; +GEOG_LENGTH: 'GEOG_LENGTH' | 'geog_length'; +GEOG_PERIMETER: 'GEOG_PERIMETER' | 'geog_perimeter'; +GEOM_IS_EMPTY: 'GEOM_IS_EMPTY' | 'geo_is_empty'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 09ae3962b7..2a9534df5b 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -342,6 +342,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -8792,6 +8796,38 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(GeomAzimuthLogicalFunction(std::move(arg0), std::move(arg1))); } /* END CODEGEN PARSER GLUE: GEOM_AZIMUTH */ + case AntlrSQLParser::GEOG_AREA: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeogArea requires 1 arg but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeogAreaLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOG_AREA */ + case AntlrSQLParser::GEOG_LENGTH: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeogLength requires 1 arg but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeogLengthLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOG_LENGTH */ + case AntlrSQLParser::GEOG_PERIMETER: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeogPerimeter requires 1 arg but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeogPerimeterLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOG_PERIMETER */ + case AntlrSQLParser::GEOM_IS_EMPTY: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeomIsEmpty requires 1 arg but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeomIsEmptyLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOM_IS_EMPTY */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 5139621689245fde24456b5d17355739d06f371b Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Sun, 14 Jun 2026 15:42:49 +0200 Subject: [PATCH 51/86] feat(meos): add AINTERSECTS/ACOVERS/ADISJOINT/ADWITHIN_TGEO_GEO NES operators (W103) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wire the always-* temporal tgeo predicate family: AINTERSECTS_TGEO_GEO, ACOVERS_TGEO_GEO, ADISJOINT_TGEO_GEO (4-arg: lon, lat, ts, wkt → FLOAT64) and ADWITHIN_TGEO_GEO (5-arg: lon, lat, ts, wkt, dist → FLOAT64). Complements the ever-* family (EDWITHIN_TGEO_GEO, ECOVERS_TGEO_GEO, EDISJOINT_TGEO_GEO). --- .../Meos/AcoversTgeoGeoLogicalFunction.hpp | 51 ++++++++ .../Meos/AdisjointTgeoGeoLogicalFunction.hpp | 51 ++++++++ .../Meos/AdwithinTgeoGeoLogicalFunction.hpp | 52 ++++++++ .../AintersectsTgeoGeoLogicalFunction.hpp | 51 ++++++++ .../Meos/AcoversTgeoGeoLogicalFunction.cpp | 107 +++++++++++++++++ .../Meos/AdisjointTgeoGeoLogicalFunction.cpp | 107 +++++++++++++++++ .../Meos/AdwithinTgeoGeoLogicalFunction.cpp | 112 ++++++++++++++++++ .../AintersectsTgeoGeoLogicalFunction.cpp | 107 +++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/AcoversTgeoGeoPhysicalFunction.hpp | 35 ++++++ .../Meos/AdisjointTgeoGeoPhysicalFunction.hpp | 35 ++++++ .../Meos/AdwithinTgeoGeoPhysicalFunction.hpp | 36 ++++++ .../AintersectsTgeoGeoPhysicalFunction.hpp | 35 ++++++ .../Meos/AcoversTgeoGeoPhysicalFunction.cpp | 87 ++++++++++++++ .../Meos/AdisjointTgeoGeoPhysicalFunction.cpp | 87 ++++++++++++++ .../Meos/AdwithinTgeoGeoPhysicalFunction.cpp | 91 ++++++++++++++ .../AintersectsTgeoGeoPhysicalFunction.cpp | 87 ++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 49 ++++++++ 20 files changed, 1193 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AcoversTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AdisjointTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AdwithinTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AintersectsTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AcoversTgeoGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AdisjointTgeoGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AdwithinTgeoGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AintersectsTgeoGeoLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AcoversTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AdisjointTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AdwithinTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AintersectsTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AcoversTgeoGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AdisjointTgeoGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AdwithinTgeoGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AintersectsTgeoGeoPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AcoversTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AcoversTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..c5c7e6823a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AcoversTgeoGeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if temporal geometry always covers the static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class AcoversTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AcoversTgeoGeo"; + + AcoversTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AdisjointTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AdisjointTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..31d5c93624 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AdisjointTgeoGeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if temporal geometry is always disjoint from the static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class AdisjointTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AdisjointTgeoGeo"; + + AdisjointTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AdwithinTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AdwithinTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..6c8088920f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AdwithinTgeoGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if temporal geometry is always within dist of the static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR, dist:FLOAT64) -> FLOAT64. + */ +class AdwithinTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AdwithinTgeoGeo"; + + AdwithinTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt, + LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AintersectsTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AintersectsTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..8223b2e12d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AintersectsTgeoGeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if temporal geometry always intersects the static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class AintersectsTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AintersectsTgeoGeo"; + + AintersectsTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AcoversTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AcoversTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..38f41209dc --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AcoversTgeoGeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AcoversTgeoGeoLogicalFunction::AcoversTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType AcoversTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AcoversTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AcoversTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AcoversTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "AcoversTgeoGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AcoversTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool AcoversTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AcoversTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AcoversTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction AcoversTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAcoversTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "AcoversTgeoGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return AcoversTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AdisjointTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AdisjointTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..d3f1b190ea --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AdisjointTgeoGeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AdisjointTgeoGeoLogicalFunction::AdisjointTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType AdisjointTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AdisjointTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AdisjointTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AdisjointTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "AdisjointTgeoGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AdisjointTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool AdisjointTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AdisjointTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AdisjointTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction AdisjointTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAdisjointTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "AdisjointTgeoGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return AdisjointTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AdwithinTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AdwithinTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..2dfe964aa3 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AdwithinTgeoGeoLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AdwithinTgeoGeoLogicalFunction::AdwithinTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt, + LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(dist)); +} + +DataType AdwithinTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AdwithinTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AdwithinTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AdwithinTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "AdwithinTgeoGeoLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AdwithinTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool AdwithinTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AdwithinTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AdwithinTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "dist must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AdwithinTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAdwithinTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "AdwithinTgeoGeoLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return AdwithinTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AintersectsTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AintersectsTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..7e1c1f035e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AintersectsTgeoGeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AintersectsTgeoGeoLogicalFunction::AintersectsTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType AintersectsTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AintersectsTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AintersectsTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AintersectsTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "AintersectsTgeoGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AintersectsTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool AintersectsTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AintersectsTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AintersectsTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction AintersectsTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAintersectsTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "AintersectsTgeoGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return AintersectsTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 47c5aa5c9c..3cffeec43f 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -295,6 +295,10 @@ add_plugin(GeogArea LogicalFunction nes-logical-operators GeogAreaLogicalFunctio add_plugin(GeogLength LogicalFunction nes-logical-operators GeogLengthLogicalFunction.cpp) add_plugin(GeogPerimeter LogicalFunction nes-logical-operators GeogPerimeterLogicalFunction.cpp) add_plugin(GeomIsEmpty LogicalFunction nes-logical-operators GeomIsEmptyLogicalFunction.cpp) +add_plugin(AintersectsTgeoGeo LogicalFunction nes-logical-operators AintersectsTgeoGeoLogicalFunction.cpp) +add_plugin(AcoversTgeoGeo LogicalFunction nes-logical-operators AcoversTgeoGeoLogicalFunction.cpp) +add_plugin(AdisjointTgeoGeo LogicalFunction nes-logical-operators AdisjointTgeoGeoLogicalFunction.cpp) +add_plugin(AdwithinTgeoGeo LogicalFunction nes-logical-operators AdwithinTgeoGeoLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-physical-operators/include/Functions/Meos/AcoversTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AcoversTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..b98adc08e9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AcoversTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AcoversTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AcoversTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AdisjointTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AdisjointTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..645e98dc41 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AdisjointTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AdisjointTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AdisjointTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AdwithinTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AdwithinTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..141a31d9ab --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AdwithinTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AdwithinTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AdwithinTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt, + PhysicalFunction dist); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AintersectsTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AintersectsTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..4ececd4f99 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AintersectsTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AintersectsTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AintersectsTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AcoversTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AcoversTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..2ed4f96b36 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AcoversTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AcoversTgeoGeoPhysicalFunction::AcoversTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal AcoversTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + int r = acovers_tgeo_geo(tgeo, gs); + free(tgeo); free(gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAcoversTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "AcoversTgeoGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return AcoversTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AdisjointTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AdisjointTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..0f63cbf5d2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AdisjointTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AdisjointTgeoGeoPhysicalFunction::AdisjointTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal AdisjointTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + int r = adisjoint_tgeo_geo(tgeo, gs); + free(tgeo); free(gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAdisjointTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "AdisjointTgeoGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return AdisjointTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AdwithinTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AdwithinTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..f46ab72996 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AdwithinTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AdwithinTgeoGeoPhysicalFunction::AdwithinTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt, + PhysicalFunction dist) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(dist)); +} + +VarVal AdwithinTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + auto dist = paramFns[4].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz, double dist) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + int r = adwithin_tgeo_geo(tgeo, gs, dist); + free(tgeo); free(gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt, dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAdwithinTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "AdwithinTgeoGeoPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return AdwithinTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AintersectsTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AintersectsTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..df6f10ca10 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AintersectsTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AintersectsTgeoGeoPhysicalFunction::AintersectsTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal AintersectsTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + int r = aintersects_tgeo_geo(tgeo, gs); + free(tgeo); free(gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAintersectsTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "AintersectsTgeoGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return AintersectsTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index ee1cd1b7c4..c64f1e8f7e 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -294,6 +294,10 @@ add_plugin(GeogArea PhysicalFunction nes-physical-operators GeogAreaPhysicalFunc add_plugin(GeogLength PhysicalFunction nes-physical-operators GeogLengthPhysicalFunction.cpp) add_plugin(GeogPerimeter PhysicalFunction nes-physical-operators GeogPerimeterPhysicalFunction.cpp) add_plugin(GeomIsEmpty PhysicalFunction nes-physical-operators GeomIsEmptyPhysicalFunction.cpp) +add_plugin(AintersectsTgeoGeo PhysicalFunction nes-physical-operators AintersectsTgeoGeoPhysicalFunction.cpp) +add_plugin(AcoversTgeoGeo PhysicalFunction nes-physical-operators AcoversTgeoGeoPhysicalFunction.cpp) +add_plugin(AdisjointTgeoGeo PhysicalFunction nes-physical-operators AdisjointTgeoGeoPhysicalFunction.cpp) +add_plugin(AdwithinTgeoGeo PhysicalFunction nes-physical-operators AdwithinTgeoGeoPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index ded03b8e29..ef432428da 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -765,6 +765,10 @@ GEOG_AREA: 'GEOG_AREA' | 'geog_area'; GEOG_LENGTH: 'GEOG_LENGTH' | 'geog_length'; GEOG_PERIMETER: 'GEOG_PERIMETER' | 'geog_perimeter'; GEOM_IS_EMPTY: 'GEOM_IS_EMPTY' | 'geo_is_empty'; +AINTERSECTS_TGEO_GEO: 'AINTERSECTS_TGEO_GEO' | 'aintersects_tgeo_geo'; +ACOVERS_TGEO_GEO: 'ACOVERS_TGEO_GEO' | 'acovers_tgeo_geo'; +ADISJOINT_TGEO_GEO: 'ADISJOINT_TGEO_GEO' | 'adisjoint_tgeo_geo'; +ADWITHIN_TGEO_GEO: 'ADWITHIN_TGEO_GEO' | 'adwithin_tgeo_geo'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 2a9534df5b..3960df030f 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -346,6 +346,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -8828,6 +8832,51 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(GeomIsEmptyLogicalFunction(std::move(arg0))); } /* END CODEGEN PARSER GLUE: GEOM_IS_EMPTY */ + case AntlrSQLParser::AINTERSECTS_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "AintersectsTgeoGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(AintersectsTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: AINTERSECTS_TGEO_GEO */ + case AntlrSQLParser::ACOVERS_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "AcoversTgeoGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(AcoversTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: ACOVERS_TGEO_GEO */ + case AntlrSQLParser::ADISJOINT_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "AdisjointTgeoGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(AdisjointTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: ADISJOINT_TGEO_GEO */ + case AntlrSQLParser::ADWITHIN_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 5, + "AdwithinTgeoGeo requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(AdwithinTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: ADWITHIN_TGEO_GEO */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 8c06666627da3fd208a74529df13357a4ea6bdfe Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Sun, 14 Jun 2026 15:47:42 +0200 Subject: [PATCH 52/86] feat(meos): add EINTERSECTS/ETOUCHES/ECONTAINS/ACONTAINS/ATOUCHES_TGEO_GEO NES operators (W104) Wire five remaining tgeo predicate operators: EINTERSECTS_TGEO_GEO, ETOUCHES_TGEO_GEO, ECONTAINS_TGEO_GEO (ever-*) and ACONTAINS_TGEO_GEO, ATOUCHES_TGEO_GEO (always-*). All use the 4-arg pattern (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. --- .../Meos/AcontainsTgeoGeoLogicalFunction.hpp | 51 +++++++++ .../Meos/AtouchesTgeoGeoLogicalFunction.hpp | 51 +++++++++ .../Meos/EcontainsTgeoGeoLogicalFunction.hpp | 51 +++++++++ .../EintersectsTgeoGeoLogicalFunction.hpp | 51 +++++++++ .../Meos/EtouchesTgeoGeoLogicalFunction.hpp | 51 +++++++++ .../Meos/AcontainsTgeoGeoLogicalFunction.cpp | 107 ++++++++++++++++++ .../Meos/AtouchesTgeoGeoLogicalFunction.cpp | 107 ++++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../Meos/EcontainsTgeoGeoLogicalFunction.cpp | 107 ++++++++++++++++++ .../EintersectsTgeoGeoLogicalFunction.cpp | 107 ++++++++++++++++++ .../Meos/EtouchesTgeoGeoLogicalFunction.cpp | 107 ++++++++++++++++++ .../Meos/AcontainsTgeoGeoPhysicalFunction.hpp | 35 ++++++ .../Meos/AtouchesTgeoGeoPhysicalFunction.hpp | 35 ++++++ .../Meos/EcontainsTgeoGeoPhysicalFunction.hpp | 35 ++++++ .../EintersectsTgeoGeoPhysicalFunction.hpp | 35 ++++++ .../Meos/EtouchesTgeoGeoPhysicalFunction.hpp | 35 ++++++ .../Meos/AcontainsTgeoGeoPhysicalFunction.cpp | 87 ++++++++++++++ .../Meos/AtouchesTgeoGeoPhysicalFunction.cpp | 87 ++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../Meos/EcontainsTgeoGeoPhysicalFunction.cpp | 87 ++++++++++++++ .../EintersectsTgeoGeoPhysicalFunction.cpp | 87 ++++++++++++++ .../Meos/EtouchesTgeoGeoPhysicalFunction.cpp | 87 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 7 +- .../src/AntlrSQLQueryPlanCreator.cpp | 65 +++++++++++ 24 files changed, 1481 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AcontainsTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AtouchesTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EcontainsTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EintersectsTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EtouchesTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AcontainsTgeoGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AtouchesTgeoGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EcontainsTgeoGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EintersectsTgeoGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EtouchesTgeoGeoLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AcontainsTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AtouchesTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EcontainsTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EintersectsTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EtouchesTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AcontainsTgeoGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AtouchesTgeoGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EcontainsTgeoGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EintersectsTgeoGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EtouchesTgeoGeoPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AcontainsTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AcontainsTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..d713a4c754 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AcontainsTgeoGeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if temporal geometry always contains the static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class AcontainsTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AcontainsTgeoGeo"; + + AcontainsTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AtouchesTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AtouchesTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..5c0fe22dab --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AtouchesTgeoGeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if temporal geometry always touches the static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class AtouchesTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AtouchesTgeoGeo"; + + AtouchesTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EcontainsTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EcontainsTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..c016ba2edf --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EcontainsTgeoGeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if temporal geometry ever contains the static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class EcontainsTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EcontainsTgeoGeo"; + + EcontainsTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EintersectsTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EintersectsTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..e98c349738 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EintersectsTgeoGeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if temporal geometry ever intersects the static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class EintersectsTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EintersectsTgeoGeo"; + + EintersectsTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EtouchesTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EtouchesTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..b1db05cb86 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EtouchesTgeoGeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if temporal geometry ever touches the static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class EtouchesTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EtouchesTgeoGeo"; + + EtouchesTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AcontainsTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AcontainsTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..b4ded1a783 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AcontainsTgeoGeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AcontainsTgeoGeoLogicalFunction::AcontainsTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType AcontainsTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AcontainsTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AcontainsTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AcontainsTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "AcontainsTgeoGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AcontainsTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool AcontainsTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AcontainsTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AcontainsTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction AcontainsTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAcontainsTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "AcontainsTgeoGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return AcontainsTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AtouchesTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AtouchesTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..a92566dc79 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AtouchesTgeoGeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AtouchesTgeoGeoLogicalFunction::AtouchesTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType AtouchesTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AtouchesTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AtouchesTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AtouchesTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "AtouchesTgeoGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AtouchesTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool AtouchesTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AtouchesTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AtouchesTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction AtouchesTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAtouchesTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "AtouchesTgeoGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return AtouchesTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 3cffeec43f..6f3276bfae 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -299,6 +299,11 @@ add_plugin(AintersectsTgeoGeo LogicalFunction nes-logical-operators AintersectsT add_plugin(AcoversTgeoGeo LogicalFunction nes-logical-operators AcoversTgeoGeoLogicalFunction.cpp) add_plugin(AdisjointTgeoGeo LogicalFunction nes-logical-operators AdisjointTgeoGeoLogicalFunction.cpp) add_plugin(AdwithinTgeoGeo LogicalFunction nes-logical-operators AdwithinTgeoGeoLogicalFunction.cpp) +add_plugin(EintersectsTgeoGeo LogicalFunction nes-logical-operators EintersectsTgeoGeoLogicalFunction.cpp) +add_plugin(EtouchesTgeoGeo LogicalFunction nes-logical-operators EtouchesTgeoGeoLogicalFunction.cpp) +add_plugin(EcontainsTgeoGeo LogicalFunction nes-logical-operators EcontainsTgeoGeoLogicalFunction.cpp) +add_plugin(AcontainsTgeoGeo LogicalFunction nes-logical-operators AcontainsTgeoGeoLogicalFunction.cpp) +add_plugin(AtouchesTgeoGeo LogicalFunction nes-logical-operators AtouchesTgeoGeoLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EcontainsTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EcontainsTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..a0634dd701 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EcontainsTgeoGeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EcontainsTgeoGeoLogicalFunction::EcontainsTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType EcontainsTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EcontainsTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EcontainsTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EcontainsTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "EcontainsTgeoGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EcontainsTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool EcontainsTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EcontainsTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EcontainsTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction EcontainsTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEcontainsTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "EcontainsTgeoGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return EcontainsTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EintersectsTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EintersectsTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..69673fe97c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EintersectsTgeoGeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EintersectsTgeoGeoLogicalFunction::EintersectsTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType EintersectsTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EintersectsTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EintersectsTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EintersectsTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "EintersectsTgeoGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EintersectsTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool EintersectsTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EintersectsTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EintersectsTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction EintersectsTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEintersectsTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "EintersectsTgeoGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return EintersectsTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EtouchesTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EtouchesTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..8232949891 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EtouchesTgeoGeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EtouchesTgeoGeoLogicalFunction::EtouchesTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType EtouchesTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EtouchesTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EtouchesTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EtouchesTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "EtouchesTgeoGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EtouchesTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool EtouchesTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EtouchesTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EtouchesTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction EtouchesTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEtouchesTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "EtouchesTgeoGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return EtouchesTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AcontainsTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AcontainsTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..37739af8b7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AcontainsTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AcontainsTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AcontainsTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AtouchesTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AtouchesTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..7cf0d71d4c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AtouchesTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AtouchesTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AtouchesTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EcontainsTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EcontainsTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..72918a88c2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EcontainsTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EcontainsTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EcontainsTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EintersectsTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EintersectsTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..0835b534c0 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EintersectsTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EintersectsTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EintersectsTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EtouchesTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EtouchesTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..d89e05afd9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EtouchesTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EtouchesTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EtouchesTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AcontainsTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AcontainsTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..6695a335d9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AcontainsTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AcontainsTgeoGeoPhysicalFunction::AcontainsTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal AcontainsTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + int r = acontains_tgeo_geo(tgeo, gs); + free(tgeo); free(gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAcontainsTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "AcontainsTgeoGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return AcontainsTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AtouchesTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AtouchesTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..a7c1d6dac1 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AtouchesTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AtouchesTgeoGeoPhysicalFunction::AtouchesTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal AtouchesTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + int r = atouches_tgeo_geo(tgeo, gs); + free(tgeo); free(gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAtouchesTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "AtouchesTgeoGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return AtouchesTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index c64f1e8f7e..655e504a7c 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -298,6 +298,11 @@ add_plugin(AintersectsTgeoGeo PhysicalFunction nes-physical-operators Aintersect add_plugin(AcoversTgeoGeo PhysicalFunction nes-physical-operators AcoversTgeoGeoPhysicalFunction.cpp) add_plugin(AdisjointTgeoGeo PhysicalFunction nes-physical-operators AdisjointTgeoGeoPhysicalFunction.cpp) add_plugin(AdwithinTgeoGeo PhysicalFunction nes-physical-operators AdwithinTgeoGeoPhysicalFunction.cpp) +add_plugin(EintersectsTgeoGeo PhysicalFunction nes-physical-operators EintersectsTgeoGeoPhysicalFunction.cpp) +add_plugin(EtouchesTgeoGeo PhysicalFunction nes-physical-operators EtouchesTgeoGeoPhysicalFunction.cpp) +add_plugin(EcontainsTgeoGeo PhysicalFunction nes-physical-operators EcontainsTgeoGeoPhysicalFunction.cpp) +add_plugin(AcontainsTgeoGeo PhysicalFunction nes-physical-operators AcontainsTgeoGeoPhysicalFunction.cpp) +add_plugin(AtouchesTgeoGeo PhysicalFunction nes-physical-operators AtouchesTgeoGeoPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EcontainsTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EcontainsTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..129536b774 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EcontainsTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EcontainsTgeoGeoPhysicalFunction::EcontainsTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal EcontainsTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + int r = econtains_tgeo_geo(tgeo, gs); + free(tgeo); free(gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEcontainsTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "EcontainsTgeoGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return EcontainsTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EintersectsTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EintersectsTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..fa8a810099 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EintersectsTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EintersectsTgeoGeoPhysicalFunction::EintersectsTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal EintersectsTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + int r = eintersects_tgeo_geo(tgeo, gs); + free(tgeo); free(gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEintersectsTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "EintersectsTgeoGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return EintersectsTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EtouchesTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EtouchesTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..f3be297dc5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EtouchesTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EtouchesTgeoGeoPhysicalFunction::EtouchesTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal EtouchesTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + int r = etouches_tgeo_geo(tgeo, gs); + free(tgeo); free(gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEtouchesTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "EtouchesTgeoGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return EtouchesTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index ef432428da..3601f338f6 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -769,6 +769,11 @@ AINTERSECTS_TGEO_GEO: 'AINTERSECTS_TGEO_GEO' | 'aintersects_tgeo_geo'; ACOVERS_TGEO_GEO: 'ACOVERS_TGEO_GEO' | 'acovers_tgeo_geo'; ADISJOINT_TGEO_GEO: 'ADISJOINT_TGEO_GEO' | 'adisjoint_tgeo_geo'; ADWITHIN_TGEO_GEO: 'ADWITHIN_TGEO_GEO' | 'adwithin_tgeo_geo'; +EINTERSECTS_TGEO_GEO: 'EINTERSECTS_TGEO_GEO' | 'eintersects_tgeo_geo'; +ETOUCHES_TGEO_GEO: 'ETOUCHES_TGEO_GEO' | 'etouches_tgeo_geo'; +ECONTAINS_TGEO_GEO: 'ECONTAINS_TGEO_GEO' | 'econtains_tgeo_geo'; +ACONTAINS_TGEO_GEO: 'ACONTAINS_TGEO_GEO' | 'acontains_tgeo_geo'; +ATOUCHES_TGEO_GEO: 'ATOUCHES_TGEO_GEO' | 'atouches_tgeo_geo'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 3960df030f..aa48a4cd48 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -350,6 +350,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -8877,6 +8882,66 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(AdwithinTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); } /* END CODEGEN PARSER GLUE: ADWITHIN_TGEO_GEO */ + case AntlrSQLParser::EINTERSECTS_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "EintersectsTgeoGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(EintersectsTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), + std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: EINTERSECTS_TGEO_GEO */ + case AntlrSQLParser::ETOUCHES_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "EtouchesTgeoGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(EtouchesTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), + std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: ETOUCHES_TGEO_GEO */ + case AntlrSQLParser::ECONTAINS_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "EcontainsTgeoGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(EcontainsTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), + std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: ECONTAINS_TGEO_GEO */ + case AntlrSQLParser::ACONTAINS_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "AcontainsTgeoGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(AcontainsTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), + std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: ACONTAINS_TGEO_GEO */ + case AntlrSQLParser::ATOUCHES_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "AtouchesTgeoGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(AtouchesTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), + std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: ATOUCHES_TGEO_GEO */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From bbc00174c7c8f5a52b251f6889c6cdbd22b1afd1 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 00:13:39 +0200 Subject: [PATCH 53/86] feat(meos): add GEO_NUM_POINTS/GEOS/SRID/IS_UNITARY, GEO_EQUALS/SAME, GEOG_DISTANCE NES operators (W105) Wire seven static geometry scalar operators: GEO_NUM_POINTS, GEO_NUM_GEOS, GEO_SRID, GEO_IS_UNITARY (1-arg VARCHAR->FLOAT64) and GEO_EQUALS, GEO_SAME, GEOG_DISTANCE (2-arg VARCHAR*VARCHAR->FLOAT64). --- .../Meos/GeoEqualsLogicalFunction.hpp | 50 ++++++++++ .../Meos/GeoIsUnitaryLogicalFunction.hpp | 50 ++++++++++ .../Meos/GeoNumGeosLogicalFunction.hpp | 50 ++++++++++ .../Meos/GeoNumPointsLogicalFunction.hpp | 50 ++++++++++ .../Functions/Meos/GeoSameLogicalFunction.hpp | 50 ++++++++++ .../Functions/Meos/GeoSridLogicalFunction.hpp | 50 ++++++++++ .../Meos/GeogDistanceLogicalFunction.hpp | 50 ++++++++++ .../src/Functions/Meos/CMakeLists.txt | 7 ++ .../Meos/GeoEqualsLogicalFunction.cpp | 98 +++++++++++++++++++ .../Meos/GeoIsUnitaryLogicalFunction.cpp | 94 ++++++++++++++++++ .../Meos/GeoNumGeosLogicalFunction.cpp | 94 ++++++++++++++++++ .../Meos/GeoNumPointsLogicalFunction.cpp | 94 ++++++++++++++++++ .../Functions/Meos/GeoSameLogicalFunction.cpp | 98 +++++++++++++++++++ .../Functions/Meos/GeoSridLogicalFunction.cpp | 94 ++++++++++++++++++ .../Meos/GeogDistanceLogicalFunction.cpp | 98 +++++++++++++++++++ .../Meos/GeoEqualsPhysicalFunction.hpp | 34 +++++++ .../Meos/GeoIsUnitaryPhysicalFunction.hpp | 34 +++++++ .../Meos/GeoNumGeosPhysicalFunction.hpp | 34 +++++++ .../Meos/GeoNumPointsPhysicalFunction.hpp | 34 +++++++ .../Meos/GeoSamePhysicalFunction.hpp | 34 +++++++ .../Meos/GeoSridPhysicalFunction.hpp | 34 +++++++ .../Meos/GeogDistancePhysicalFunction.hpp | 34 +++++++ .../src/Functions/Meos/CMakeLists.txt | 7 ++ .../Meos/GeoEqualsPhysicalFunction.cpp | 78 +++++++++++++++ .../Meos/GeoIsUnitaryPhysicalFunction.cpp | 72 ++++++++++++++ .../Meos/GeoNumGeosPhysicalFunction.cpp | 72 ++++++++++++++ .../Meos/GeoNumPointsPhysicalFunction.cpp | 72 ++++++++++++++ .../Meos/GeoSamePhysicalFunction.cpp | 78 +++++++++++++++ .../Meos/GeoSridPhysicalFunction.cpp | 72 ++++++++++++++ .../Meos/GeogDistancePhysicalFunction.cpp | 78 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 9 +- .../src/AntlrSQLQueryPlanCreator.cpp | 66 +++++++++++++ 32 files changed, 1868 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeoEqualsLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeoIsUnitaryLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeoNumGeosLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeoNumPointsLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeoSameLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeoSridLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeogDistanceLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoEqualsLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoIsUnitaryLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoNumGeosLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoNumPointsLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoSameLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoSridLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeogDistanceLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoEqualsPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoIsUnitaryPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoNumGeosPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoNumPointsPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoSamePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoSridPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeogDistancePhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoEqualsPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoIsUnitaryPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoNumGeosPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoNumPointsPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoSamePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoSridPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeogDistancePhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeoEqualsLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoEqualsLogicalFunction.hpp new file mode 100644 index 0000000000..abe64d136c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoEqualsLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if two planar geometries are spatially equal. + * + * Args: (wkt1:VARCHAR, wkt2:VARCHAR) -> FLOAT64. + */ +class GeoEqualsLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoEquals"; + + GeoEqualsLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeoIsUnitaryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoIsUnitaryLogicalFunction.hpp new file mode 100644 index 0000000000..f59d45cc61 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoIsUnitaryLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the geometry is a single geometry (not a collection). + * + * Args: (wkt:VARCHAR) -> FLOAT64. + */ +class GeoIsUnitaryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoIsUnitary"; + + explicit GeoIsUnitaryLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeoNumGeosLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoNumGeosLogicalFunction.hpp new file mode 100644 index 0000000000..d6845bc10b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoNumGeosLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the number of sub-geometries in a geometry collection. + * + * Args: (wkt:VARCHAR) -> FLOAT64. + */ +class GeoNumGeosLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoNumGeos"; + + explicit GeoNumGeosLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeoNumPointsLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoNumPointsLogicalFunction.hpp new file mode 100644 index 0000000000..198b5f3dae --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoNumPointsLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the number of points in a geometry. + * + * Args: (wkt:VARCHAR) -> FLOAT64. + */ +class GeoNumPointsLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoNumPoints"; + + explicit GeoNumPointsLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeoSameLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoSameLogicalFunction.hpp new file mode 100644 index 0000000000..277b6790a1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoSameLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if two planar geometries are the same (identical coordinates). + * + * Args: (wkt1:VARCHAR, wkt2:VARCHAR) -> FLOAT64. + */ +class GeoSameLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoSame"; + + GeoSameLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeoSridLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoSridLogicalFunction.hpp new file mode 100644 index 0000000000..7d539b2d64 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoSridLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the SRID of a geometry. + * + * Args: (wkt:VARCHAR) -> FLOAT64. + */ +class GeoSridLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoSrid"; + + explicit GeoSridLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeogDistanceLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeogDistanceLogicalFunction.hpp new file mode 100644 index 0000000000..f9868257b3 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeogDistanceLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the spheroidal distance between two geographic geometries in metres. + * + * Args: (wkt1:VARCHAR, wkt2:VARCHAR) -> FLOAT64. + */ +class GeogDistanceLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeogDistance"; + + GeogDistanceLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 6f3276bfae..0314be0a6d 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -304,6 +304,13 @@ add_plugin(EtouchesTgeoGeo LogicalFunction nes-logical-operators EtouchesTgeoGeo add_plugin(EcontainsTgeoGeo LogicalFunction nes-logical-operators EcontainsTgeoGeoLogicalFunction.cpp) add_plugin(AcontainsTgeoGeo LogicalFunction nes-logical-operators AcontainsTgeoGeoLogicalFunction.cpp) add_plugin(AtouchesTgeoGeo LogicalFunction nes-logical-operators AtouchesTgeoGeoLogicalFunction.cpp) +add_plugin(GeoNumPoints LogicalFunction nes-logical-operators GeoNumPointsLogicalFunction.cpp) +add_plugin(GeoNumGeos LogicalFunction nes-logical-operators GeoNumGeosLogicalFunction.cpp) +add_plugin(GeoSrid LogicalFunction nes-logical-operators GeoSridLogicalFunction.cpp) +add_plugin(GeoIsUnitary LogicalFunction nes-logical-operators GeoIsUnitaryLogicalFunction.cpp) +add_plugin(GeoEquals LogicalFunction nes-logical-operators GeoEqualsLogicalFunction.cpp) +add_plugin(GeoSame LogicalFunction nes-logical-operators GeoSameLogicalFunction.cpp) +add_plugin(GeogDistance LogicalFunction nes-logical-operators GeogDistanceLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeoEqualsLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoEqualsLogicalFunction.cpp new file mode 100644 index 0000000000..48b4b40aa1 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoEqualsLogicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoEqualsLogicalFunction::GeoEqualsLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeoEqualsLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoEqualsLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoEqualsLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoEqualsLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeoEqualsLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoEqualsLogicalFunction::getType() const { return NAME; } + +bool GeoEqualsLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoEqualsLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoEqualsLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeoEqualsLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoEqualsLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeoEqualsLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeoEqualsLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeoIsUnitaryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoIsUnitaryLogicalFunction.cpp new file mode 100644 index 0000000000..b3f1f32798 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoIsUnitaryLogicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoIsUnitaryLogicalFunction::GeoIsUnitaryLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeoIsUnitaryLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoIsUnitaryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoIsUnitaryLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoIsUnitaryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeoIsUnitaryLogicalFunction requires 1 child, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoIsUnitaryLogicalFunction::getType() const { return NAME; } + +bool GeoIsUnitaryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoIsUnitaryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoIsUnitaryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + c.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeoIsUnitaryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoIsUnitaryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeoIsUnitaryLogicalFunction requires 1 child but got {}", + arguments.children.size()); + return GeoIsUnitaryLogicalFunction(std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeoNumGeosLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoNumGeosLogicalFunction.cpp new file mode 100644 index 0000000000..f12ce09ac8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoNumGeosLogicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoNumGeosLogicalFunction::GeoNumGeosLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeoNumGeosLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoNumGeosLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoNumGeosLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoNumGeosLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeoNumGeosLogicalFunction requires 1 child, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoNumGeosLogicalFunction::getType() const { return NAME; } + +bool GeoNumGeosLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoNumGeosLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoNumGeosLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + c.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeoNumGeosLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoNumGeosLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeoNumGeosLogicalFunction requires 1 child but got {}", + arguments.children.size()); + return GeoNumGeosLogicalFunction(std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeoNumPointsLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoNumPointsLogicalFunction.cpp new file mode 100644 index 0000000000..740184d839 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoNumPointsLogicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoNumPointsLogicalFunction::GeoNumPointsLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeoNumPointsLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoNumPointsLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoNumPointsLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoNumPointsLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeoNumPointsLogicalFunction requires 1 child, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoNumPointsLogicalFunction::getType() const { return NAME; } + +bool GeoNumPointsLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoNumPointsLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoNumPointsLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + c.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeoNumPointsLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoNumPointsLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeoNumPointsLogicalFunction requires 1 child but got {}", + arguments.children.size()); + return GeoNumPointsLogicalFunction(std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeoSameLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoSameLogicalFunction.cpp new file mode 100644 index 0000000000..658068a60c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoSameLogicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoSameLogicalFunction::GeoSameLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeoSameLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoSameLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoSameLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoSameLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeoSameLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoSameLogicalFunction::getType() const { return NAME; } + +bool GeoSameLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoSameLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoSameLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeoSameLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoSameLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeoSameLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeoSameLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeoSridLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoSridLogicalFunction.cpp new file mode 100644 index 0000000000..a98433ec51 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoSridLogicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoSridLogicalFunction::GeoSridLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeoSridLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoSridLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoSridLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoSridLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeoSridLogicalFunction requires 1 child, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoSridLogicalFunction::getType() const { return NAME; } + +bool GeoSridLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoSridLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoSridLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + c.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeoSridLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoSridLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeoSridLogicalFunction requires 1 child but got {}", + arguments.children.size()); + return GeoSridLogicalFunction(std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeogDistanceLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeogDistanceLogicalFunction.cpp new file mode 100644 index 0000000000..ac2b16b3f0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeogDistanceLogicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeogDistanceLogicalFunction::GeogDistanceLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeogDistanceLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeogDistanceLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeogDistanceLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeogDistanceLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeogDistanceLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeogDistanceLogicalFunction::getType() const { return NAME; } + +bool GeogDistanceLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeogDistanceLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeogDistanceLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeogDistanceLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeogDistanceLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeogDistanceLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeogDistanceLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoEqualsPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoEqualsPhysicalFunction.hpp new file mode 100644 index 0000000000..c3f9b3222a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoEqualsPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoEqualsPhysicalFunction : public PhysicalFunctionConcept { +public: + GeoEqualsPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoIsUnitaryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoIsUnitaryPhysicalFunction.hpp new file mode 100644 index 0000000000..ed45b95057 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoIsUnitaryPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoIsUnitaryPhysicalFunction : public PhysicalFunctionConcept { +public: + explicit GeoIsUnitaryPhysicalFunction(PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoNumGeosPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoNumGeosPhysicalFunction.hpp new file mode 100644 index 0000000000..98f5925b9b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoNumGeosPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoNumGeosPhysicalFunction : public PhysicalFunctionConcept { +public: + explicit GeoNumGeosPhysicalFunction(PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoNumPointsPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoNumPointsPhysicalFunction.hpp new file mode 100644 index 0000000000..d3f0c444a2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoNumPointsPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoNumPointsPhysicalFunction : public PhysicalFunctionConcept { +public: + explicit GeoNumPointsPhysicalFunction(PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoSamePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoSamePhysicalFunction.hpp new file mode 100644 index 0000000000..a2053e8731 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoSamePhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoSamePhysicalFunction : public PhysicalFunctionConcept { +public: + GeoSamePhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoSridPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoSridPhysicalFunction.hpp new file mode 100644 index 0000000000..3e452c1ec7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoSridPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoSridPhysicalFunction : public PhysicalFunctionConcept { +public: + explicit GeoSridPhysicalFunction(PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeogDistancePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeogDistancePhysicalFunction.hpp new file mode 100644 index 0000000000..de46d9e42d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeogDistancePhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeogDistancePhysicalFunction : public PhysicalFunctionConcept { +public: + GeogDistancePhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 655e504a7c..b7dc042dee 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -303,6 +303,13 @@ add_plugin(EtouchesTgeoGeo PhysicalFunction nes-physical-operators EtouchesTgeoG add_plugin(EcontainsTgeoGeo PhysicalFunction nes-physical-operators EcontainsTgeoGeoPhysicalFunction.cpp) add_plugin(AcontainsTgeoGeo PhysicalFunction nes-physical-operators AcontainsTgeoGeoPhysicalFunction.cpp) add_plugin(AtouchesTgeoGeo PhysicalFunction nes-physical-operators AtouchesTgeoGeoPhysicalFunction.cpp) +add_plugin(GeoNumPoints PhysicalFunction nes-physical-operators GeoNumPointsPhysicalFunction.cpp) +add_plugin(GeoNumGeos PhysicalFunction nes-physical-operators GeoNumGeosPhysicalFunction.cpp) +add_plugin(GeoSrid PhysicalFunction nes-physical-operators GeoSridPhysicalFunction.cpp) +add_plugin(GeoIsUnitary PhysicalFunction nes-physical-operators GeoIsUnitaryPhysicalFunction.cpp) +add_plugin(GeoEquals PhysicalFunction nes-physical-operators GeoEqualsPhysicalFunction.cpp) +add_plugin(GeoSame PhysicalFunction nes-physical-operators GeoSamePhysicalFunction.cpp) +add_plugin(GeogDistance PhysicalFunction nes-physical-operators GeogDistancePhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/GeoEqualsPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoEqualsPhysicalFunction.cpp new file mode 100644 index 0000000000..6738dce23f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoEqualsPhysicalFunction.cpp @@ -0,0 +1,78 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoEqualsPhysicalFunction::GeoEqualsPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); +} + +VarVal GeoEqualsPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto s1 = paramFns[0].execute(record, arena).cast(); + auto s2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + std::string s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + double r = (double)geo_equals(gs1, gs2); + free(gs1); free(gs2); + return r; + } catch (const std::exception&) { return 0.0; } + }, + s1, s2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoEqualsPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeoEqualsPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeoEqualsPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeoIsUnitaryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoIsUnitaryPhysicalFunction.cpp new file mode 100644 index 0000000000..703403de4d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoIsUnitaryPhysicalFunction.cpp @@ -0,0 +1,72 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoIsUnitaryPhysicalFunction::GeoIsUnitaryPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeoIsUnitaryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto s1 = paramFns[0].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + double r = geo_is_unitary(gs1) ? 1.0 : 0.0; + free(gs1); + return r; + } catch (const std::exception&) { return 0.0; } + }, + s1); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoIsUnitaryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeoIsUnitaryPhysicalFunction requires 1 child but got {}", + arguments.childFunctions.size()); + return GeoIsUnitaryPhysicalFunction(std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeoNumGeosPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoNumGeosPhysicalFunction.cpp new file mode 100644 index 0000000000..fe4373d05e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoNumGeosPhysicalFunction.cpp @@ -0,0 +1,72 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoNumGeosPhysicalFunction::GeoNumGeosPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeoNumGeosPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto s1 = paramFns[0].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + double r = (double)geo_num_geos(gs1); + free(gs1); + return r; + } catch (const std::exception&) { return 0.0; } + }, + s1); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoNumGeosPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeoNumGeosPhysicalFunction requires 1 child but got {}", + arguments.childFunctions.size()); + return GeoNumGeosPhysicalFunction(std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeoNumPointsPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoNumPointsPhysicalFunction.cpp new file mode 100644 index 0000000000..bee045998f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoNumPointsPhysicalFunction.cpp @@ -0,0 +1,72 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoNumPointsPhysicalFunction::GeoNumPointsPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeoNumPointsPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto s1 = paramFns[0].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + double r = (double)geo_num_points(gs1); + free(gs1); + return r; + } catch (const std::exception&) { return 0.0; } + }, + s1); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoNumPointsPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeoNumPointsPhysicalFunction requires 1 child but got {}", + arguments.childFunctions.size()); + return GeoNumPointsPhysicalFunction(std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeoSamePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoSamePhysicalFunction.cpp new file mode 100644 index 0000000000..3bf6a98d77 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoSamePhysicalFunction.cpp @@ -0,0 +1,78 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoSamePhysicalFunction::GeoSamePhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); +} + +VarVal GeoSamePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto s1 = paramFns[0].execute(record, arena).cast(); + auto s2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + std::string s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + double r = geo_same(gs1, gs2) ? 1.0 : 0.0; + free(gs1); free(gs2); + return r; + } catch (const std::exception&) { return 0.0; } + }, + s1, s2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoSamePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeoSamePhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeoSamePhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeoSridPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoSridPhysicalFunction.cpp new file mode 100644 index 0000000000..4da9726a29 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoSridPhysicalFunction.cpp @@ -0,0 +1,72 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoSridPhysicalFunction::GeoSridPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeoSridPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto s1 = paramFns[0].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + double r = (double)geo_srid(gs1); + free(gs1); + return r; + } catch (const std::exception&) { return 0.0; } + }, + s1); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoSridPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeoSridPhysicalFunction requires 1 child but got {}", + arguments.childFunctions.size()); + return GeoSridPhysicalFunction(std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeogDistancePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeogDistancePhysicalFunction.cpp new file mode 100644 index 0000000000..552fff69e4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeogDistancePhysicalFunction.cpp @@ -0,0 +1,78 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeogDistancePhysicalFunction::GeogDistancePhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); +} + +VarVal GeogDistancePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto s1 = paramFns[0].execute(record, arena).cast(); + auto s2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + std::string s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + double r = geog_distance(gs1, gs2); + free(gs1); free(gs2); + return r; + } catch (const std::exception&) { return 0.0; } + }, + s1, s2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeogDistancePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeogDistancePhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeogDistancePhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 3601f338f6..5904cdc389 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -774,6 +774,13 @@ ETOUCHES_TGEO_GEO: 'ETOUCHES_TGEO_GEO' | 'etouches_tgeo_geo'; ECONTAINS_TGEO_GEO: 'ECONTAINS_TGEO_GEO' | 'econtains_tgeo_geo'; ACONTAINS_TGEO_GEO: 'ACONTAINS_TGEO_GEO' | 'acontains_tgeo_geo'; ATOUCHES_TGEO_GEO: 'ATOUCHES_TGEO_GEO' | 'atouches_tgeo_geo'; +GEO_NUM_POINTS: 'GEO_NUM_POINTS' | 'geo_num_points'; +GEO_NUM_GEOS: 'GEO_NUM_GEOS' | 'geo_num_geos'; +GEO_SRID: 'GEO_SRID' | 'geo_srid'; +GEO_IS_UNITARY: 'GEO_IS_UNITARY' | 'geo_is_unitary'; +GEO_EQUALS: 'GEO_EQUALS' | 'geo_equals'; +GEO_SAME: 'GEO_SAME' | 'geo_same'; +GEOG_DISTANCE: 'GEOG_DISTANCE' | 'geog_distance'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index aa48a4cd48..a1f0cd3e6b 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -355,6 +355,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -8942,6 +8949,65 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont std::move(arg2), std::move(arg3))); } /* END CODEGEN PARSER GLUE: ATOUCHES_TGEO_GEO */ + case AntlrSQLParser::GEO_NUM_POINTS: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeoNumPoints requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeoNumPointsLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEO_NUM_POINTS */ + case AntlrSQLParser::GEO_NUM_GEOS: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeoNumGeos requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeoNumGeosLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEO_NUM_GEOS */ + case AntlrSQLParser::GEO_SRID: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeoSrid requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeoSridLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEO_SRID */ + case AntlrSQLParser::GEO_IS_UNITARY: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeoIsUnitary requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeoIsUnitaryLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEO_IS_UNITARY */ + case AntlrSQLParser::GEO_EQUALS: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeoEquals requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeoEqualsLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEO_EQUALS */ + case AntlrSQLParser::GEO_SAME: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeoSame requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeoSameLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEO_SAME */ + case AntlrSQLParser::GEOG_DISTANCE: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeogDistance requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeogDistanceLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOG_DISTANCE */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 5974ba8be32c1c59111aa4d924c1b9ef2dfdfeaa Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 00:13:39 +0200 Subject: [PATCH 54/86] feat(meos): add NAD_TGEO_GEO nearest-approach distance NES operator (W106) Wires nad_tgeo_geo as a 4-arg (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64 NES operator backed by the MEOS kernel. --- .../Meos/NadTgeoGeoLogicalFunction.hpp | 51 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 1 + .../Meos/NadTgeoGeoLogicalFunction.cpp | 107 ++++++++++++++++++ .../Meos/NadTgeoGeoPhysicalFunction.hpp | 35 ++++++ .../src/Functions/Meos/CMakeLists.txt | 1 + .../Meos/NadTgeoGeoPhysicalFunction.cpp | 87 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 3 +- .../src/AntlrSQLQueryPlanCreator.cpp | 12 ++ 8 files changed, 296 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/NadTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/NadTgeoGeoLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/NadTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/NadTgeoGeoPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/NadTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/NadTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..7df28e013d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/NadTgeoGeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nearest approach distance between a temporal geometry and a static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class NadTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "NadTgeoGeo"; + + NadTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 0314be0a6d..84463aa354 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -311,6 +311,7 @@ add_plugin(GeoIsUnitary LogicalFunction nes-logical-operators GeoIsUnitaryLogica add_plugin(GeoEquals LogicalFunction nes-logical-operators GeoEqualsLogicalFunction.cpp) add_plugin(GeoSame LogicalFunction nes-logical-operators GeoSameLogicalFunction.cpp) add_plugin(GeogDistance LogicalFunction nes-logical-operators GeogDistanceLogicalFunction.cpp) +add_plugin(NadTgeoGeo LogicalFunction nes-logical-operators NadTgeoGeoLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/NadTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/NadTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..406db3c77f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/NadTgeoGeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +NadTgeoGeoLogicalFunction::NadTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType NadTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction NadTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector NadTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction NadTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "NadTgeoGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view NadTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool NadTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string NadTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction NadTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction NadTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterNadTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "NadTgeoGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return NadTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/NadTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/NadTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..529a874595 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/NadTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class NadTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + NadTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index b7dc042dee..20c731a336 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -310,6 +310,7 @@ add_plugin(GeoIsUnitary PhysicalFunction nes-physical-operators GeoIsUnitaryPhys add_plugin(GeoEquals PhysicalFunction nes-physical-operators GeoEqualsPhysicalFunction.cpp) add_plugin(GeoSame PhysicalFunction nes-physical-operators GeoSamePhysicalFunction.cpp) add_plugin(GeogDistance PhysicalFunction nes-physical-operators GeogDistancePhysicalFunction.cpp) +add_plugin(NadTgeoGeo PhysicalFunction nes-physical-operators NadTgeoGeoPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/NadTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/NadTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..1990fd476c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/NadTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +NadTgeoGeoPhysicalFunction::NadTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal NadTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + double r = nad_tgeo_geo(tgeo, gs); + free(tgeo); free(gs); + return r; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterNadTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "NadTgeoGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return NadTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 5904cdc389..4e5851f026 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -781,6 +781,7 @@ GEO_IS_UNITARY: 'GEO_IS_UNITARY' | 'geo_is_unitary'; GEO_EQUALS: 'GEO_EQUALS' | 'geo_equals'; GEO_SAME: 'GEO_SAME' | 'geo_same'; GEOG_DISTANCE: 'GEOG_DISTANCE' | 'geog_distance'; +NAD_TGEO_GEO: 'NAD_TGEO_GEO' | 'nad_tgeo_geo'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index a1f0cd3e6b..9cab82372f 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -362,6 +362,7 @@ #include #include #include +#include #include #include #include @@ -9008,6 +9009,17 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(GeogDistanceLogicalFunction(std::move(arg0), std::move(arg1))); } /* END CODEGEN PARSER GLUE: GEOG_DISTANCE */ + case AntlrSQLParser::NAD_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "NadTgeoGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(NadTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: NAD_TGEO_GEO */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 1b1950f6610f1467c9a5f72dcd24f91c34ef6cc2 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 00:13:39 +0200 Subject: [PATCH 55/86] feat(meos): add EVER/ALWAYS_EQ/NE_TGEO_GEO NES operators (W107) Wires ever_eq_tgeo_geo, ever_ne_tgeo_geo, always_eq_tgeo_geo, and always_ne_tgeo_geo as 4-arg (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64 NES operators backed by the MEOS kernel. --- .../Meos/AlwaysEqTgeoGeoLogicalFunction.hpp | 51 +++++++++ .../Meos/AlwaysNeTgeoGeoLogicalFunction.hpp | 51 +++++++++ .../Meos/EverEqTgeoGeoLogicalFunction.hpp | 51 +++++++++ .../Meos/EverNeTgeoGeoLogicalFunction.hpp | 51 +++++++++ .../Meos/AlwaysEqTgeoGeoLogicalFunction.cpp | 107 ++++++++++++++++++ .../Meos/AlwaysNeTgeoGeoLogicalFunction.cpp | 107 ++++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/EverEqTgeoGeoLogicalFunction.cpp | 107 ++++++++++++++++++ .../Meos/EverNeTgeoGeoLogicalFunction.cpp | 107 ++++++++++++++++++ .../Meos/AlwaysEqTgeoGeoPhysicalFunction.hpp | 35 ++++++ .../Meos/AlwaysNeTgeoGeoPhysicalFunction.hpp | 35 ++++++ .../Meos/EverEqTgeoGeoPhysicalFunction.hpp | 35 ++++++ .../Meos/EverNeTgeoGeoPhysicalFunction.hpp | 35 ++++++ .../Meos/AlwaysEqTgeoGeoPhysicalFunction.cpp | 87 ++++++++++++++ .../Meos/AlwaysNeTgeoGeoPhysicalFunction.cpp | 87 ++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/EverEqTgeoGeoPhysicalFunction.cpp | 87 ++++++++++++++ .../Meos/EverNeTgeoGeoPhysicalFunction.cpp | 87 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 48 ++++++++ 20 files changed, 1181 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTgeoGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTgeoGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTgeoGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTgeoGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTgeoGeoLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTgeoGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTgeoGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTgeoGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTgeoGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTgeoGeoPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..82746232f1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTgeoGeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the temporal geometry is always equal to the static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class AlwaysEqTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTgeoGeo"; + + AlwaysEqTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..4e69287867 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTgeoGeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the temporal geometry is always not equal to the static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class AlwaysNeTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTgeoGeo"; + + AlwaysNeTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..e1909cb418 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTgeoGeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the temporal geometry is ever equal to the static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class EverEqTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTgeoGeo"; + + EverEqTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTgeoGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTgeoGeoLogicalFunction.hpp new file mode 100644 index 0000000000..1279c025bd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTgeoGeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the temporal geometry is ever not equal to the static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class EverNeTgeoGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTgeoGeo"; + + EverNeTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..34422460b8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTgeoGeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTgeoGeoLogicalFunction::AlwaysEqTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType AlwaysEqTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "AlwaysEqTgeoGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction AlwaysEqTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "AlwaysEqTgeoGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return AlwaysEqTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..e31d26ac03 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTgeoGeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTgeoGeoLogicalFunction::AlwaysNeTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType AlwaysNeTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "AlwaysNeTgeoGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction AlwaysNeTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "AlwaysNeTgeoGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return AlwaysNeTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 84463aa354..d4c84c083e 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -312,6 +312,10 @@ add_plugin(GeoEquals LogicalFunction nes-logical-operators GeoEqualsLogicalFunct add_plugin(GeoSame LogicalFunction nes-logical-operators GeoSameLogicalFunction.cpp) add_plugin(GeogDistance LogicalFunction nes-logical-operators GeogDistanceLogicalFunction.cpp) add_plugin(NadTgeoGeo LogicalFunction nes-logical-operators NadTgeoGeoLogicalFunction.cpp) +add_plugin(EverEqTgeoGeo LogicalFunction nes-logical-operators EverEqTgeoGeoLogicalFunction.cpp) +add_plugin(EverNeTgeoGeo LogicalFunction nes-logical-operators EverNeTgeoGeoLogicalFunction.cpp) +add_plugin(AlwaysEqTgeoGeo LogicalFunction nes-logical-operators AlwaysEqTgeoGeoLogicalFunction.cpp) +add_plugin(AlwaysNeTgeoGeo LogicalFunction nes-logical-operators AlwaysNeTgeoGeoLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..a3be680597 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTgeoGeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTgeoGeoLogicalFunction::EverEqTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType EverEqTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "EverEqTgeoGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool EverEqTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction EverEqTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "EverEqTgeoGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return EverEqTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTgeoGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTgeoGeoLogicalFunction.cpp new file mode 100644 index 0000000000..07ba953aef --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTgeoGeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTgeoGeoLogicalFunction::EverNeTgeoGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType EverNeTgeoGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTgeoGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTgeoGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTgeoGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "EverNeTgeoGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTgeoGeoLogicalFunction::getType() const { return NAME; } + +bool EverNeTgeoGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTgeoGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeTgeoGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED),"wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction EverNeTgeoGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTgeoGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "EverNeTgeoGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return EverNeTgeoGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..374b10708d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..e32cdf4c59 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..ae43d9ba2f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTgeoGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTgeoGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..28bad836ba --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTgeoGeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTgeoGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..d834e46c81 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTgeoGeoPhysicalFunction::AlwaysEqTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal AlwaysEqTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + double r = always_eq_tgeo_geo(tgeo, gs) > 0 ? 1.0 : 0.0; + free(tgeo); free(gs); + return r; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "AlwaysEqTgeoGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..6591e10cb6 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTgeoGeoPhysicalFunction::AlwaysNeTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal AlwaysNeTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + double r = always_ne_tgeo_geo(tgeo, gs) > 0 ? 1.0 : 0.0; + free(tgeo); free(gs); + return r; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "AlwaysNeTgeoGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 20c731a336..f955b87a94 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -311,6 +311,10 @@ add_plugin(GeoEquals PhysicalFunction nes-physical-operators GeoEqualsPhysicalFu add_plugin(GeoSame PhysicalFunction nes-physical-operators GeoSamePhysicalFunction.cpp) add_plugin(GeogDistance PhysicalFunction nes-physical-operators GeogDistancePhysicalFunction.cpp) add_plugin(NadTgeoGeo PhysicalFunction nes-physical-operators NadTgeoGeoPhysicalFunction.cpp) +add_plugin(EverEqTgeoGeo PhysicalFunction nes-physical-operators EverEqTgeoGeoPhysicalFunction.cpp) +add_plugin(EverNeTgeoGeo PhysicalFunction nes-physical-operators EverNeTgeoGeoPhysicalFunction.cpp) +add_plugin(AlwaysEqTgeoGeo PhysicalFunction nes-physical-operators AlwaysEqTgeoGeoPhysicalFunction.cpp) +add_plugin(AlwaysNeTgeoGeo PhysicalFunction nes-physical-operators AlwaysNeTgeoGeoPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..55f9b0af02 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTgeoGeoPhysicalFunction::EverEqTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal EverEqTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + double r = ever_eq_tgeo_geo(tgeo, gs) > 0 ? 1.0 : 0.0; + free(tgeo); free(gs); + return r; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "EverEqTgeoGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return EverEqTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTgeoGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTgeoGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..fd0a57634d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTgeoGeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTgeoGeoPhysicalFunction::EverNeTgeoGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal EverNeTgeoGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, uint64_t ts, + const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) return 0.0; + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) { free(tgeo); return 0.0; } + double r = ever_ne_tgeo_geo(tgeo, gs) > 0 ? 1.0 : 0.0; + free(tgeo); free(gs); + return r; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTgeoGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "EverNeTgeoGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return EverNeTgeoGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 4e5851f026..4b5e7d3a75 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -782,6 +782,10 @@ GEO_EQUALS: 'GEO_EQUALS' | 'geo_equals'; GEO_SAME: 'GEO_SAME' | 'geo_same'; GEOG_DISTANCE: 'GEOG_DISTANCE' | 'geog_distance'; NAD_TGEO_GEO: 'NAD_TGEO_GEO' | 'nad_tgeo_geo'; +EVER_EQ_TGEO_GEO: 'EVER_EQ_TGEO_GEO' | 'ever_eq_tgeo_geo'; +EVER_NE_TGEO_GEO: 'EVER_NE_TGEO_GEO' | 'ever_ne_tgeo_geo'; +ALWAYS_EQ_TGEO_GEO: 'ALWAYS_EQ_TGEO_GEO' | 'always_eq_tgeo_geo'; +ALWAYS_NE_TGEO_GEO: 'ALWAYS_NE_TGEO_GEO' | 'always_ne_tgeo_geo'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 9cab82372f..d8266caae0 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -363,6 +363,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -9020,6 +9024,50 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(NadTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); } /* END CODEGEN PARSER GLUE: NAD_TGEO_GEO */ + case AntlrSQLParser::EVER_EQ_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "EverEqTgeoGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(EverEqTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_TGEO_GEO */ + case AntlrSQLParser::EVER_NE_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "EverNeTgeoGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(EverNeTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_TGEO_GEO */ + case AntlrSQLParser::ALWAYS_EQ_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "AlwaysEqTgeoGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(AlwaysEqTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TGEO_GEO */ + case AntlrSQLParser::ALWAYS_NE_TGEO_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "AlwaysNeTgeoGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(AlwaysNeTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TGEO_GEO */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 24f8701bd0e6f12e3c2bcf987898991c58c2d91b Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 00:13:39 +0200 Subject: [PATCH 56/86] feat(meos): add GEOG_INTERSECTS and GEOG_DWITHIN NES operators (W108) Wires geog_intersects(wkt1, wkt2) as a 2-arg VARCHAR*VARCHAR -> FLOAT64 operator and geog_dwithin(wkt1, wkt2, tolerance) as a 3-arg operator, both using spheroidal (use_spheroid=true) computation via the MEOS kernel. --- .../Meos/GeogDwithinLogicalFunction.hpp | 50 +++++++++ .../Meos/GeogIntersectsLogicalFunction.hpp | 50 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../Meos/GeogDwithinLogicalFunction.cpp | 103 ++++++++++++++++++ .../Meos/GeogIntersectsLogicalFunction.cpp | 98 +++++++++++++++++ .../Meos/GeogDwithinPhysicalFunction.hpp | 34 ++++++ .../Meos/GeogIntersectsPhysicalFunction.hpp | 34 ++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../Meos/GeogDwithinPhysicalFunction.cpp | 84 ++++++++++++++ .../Meos/GeogIntersectsPhysicalFunction.cpp | 78 +++++++++++++ nes-sql-parser/AntlrSQL.g4 | 4 +- .../src/AntlrSQLQueryPlanCreator.cpp | 21 ++++ 12 files changed, 559 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeogDwithinLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeogIntersectsLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeogDwithinLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeogIntersectsLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeogDwithinPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeogIntersectsPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeogDwithinPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeogIntersectsPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeogDwithinLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeogDwithinLogicalFunction.hpp new file mode 100644 index 0000000000..bffb16c5f6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeogDwithinLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if two geographic geometries are within tolerance distance (spheroidal). + * + * Args: (wkt1:VARCHAR, wkt2:VARCHAR, tolerance:FLOAT64) -> FLOAT64. + */ +class GeogDwithinLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeogDwithin"; + + GeogDwithinLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2, LogicalFunction tolerance); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeogIntersectsLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeogIntersectsLogicalFunction.hpp new file mode 100644 index 0000000000..6be3f835fd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeogIntersectsLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if two geographic geometries intersect (spheroidal). + * + * Args: (wkt1:VARCHAR, wkt2:VARCHAR) -> FLOAT64. + */ +class GeogIntersectsLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeogIntersects"; + + GeogIntersectsLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index d4c84c083e..5df38df64e 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -316,6 +316,8 @@ add_plugin(EverEqTgeoGeo LogicalFunction nes-logical-operators EverEqTgeoGeoLogi add_plugin(EverNeTgeoGeo LogicalFunction nes-logical-operators EverNeTgeoGeoLogicalFunction.cpp) add_plugin(AlwaysEqTgeoGeo LogicalFunction nes-logical-operators AlwaysEqTgeoGeoLogicalFunction.cpp) add_plugin(AlwaysNeTgeoGeo LogicalFunction nes-logical-operators AlwaysNeTgeoGeoLogicalFunction.cpp) +add_plugin(GeogIntersects LogicalFunction nes-logical-operators GeogIntersectsLogicalFunction.cpp) +add_plugin(GeogDwithin LogicalFunction nes-logical-operators GeogDwithinLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeogDwithinLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeogDwithinLogicalFunction.cpp new file mode 100644 index 0000000000..2ddd5b07ae --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeogDwithinLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeogDwithinLogicalFunction::GeogDwithinLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2, + LogicalFunction tolerance) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); + parameters.push_back(std::move(tolerance)); +} + +DataType GeogDwithinLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeogDwithinLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeogDwithinLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeogDwithinLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "GeogDwithinLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeogDwithinLogicalFunction::getType() const { return NAME; } + +bool GeogDwithinLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeogDwithinLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeogDwithinLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "tolerance must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction GeogDwithinLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeogDwithinLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "GeogDwithinLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return GeogDwithinLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeogIntersectsLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeogIntersectsLogicalFunction.cpp new file mode 100644 index 0000000000..b51a3450c6 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeogIntersectsLogicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeogIntersectsLogicalFunction::GeogIntersectsLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeogIntersectsLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeogIntersectsLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeogIntersectsLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeogIntersectsLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeogIntersectsLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeogIntersectsLogicalFunction::getType() const { return NAME; } + +bool GeogIntersectsLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeogIntersectsLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeogIntersectsLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeogIntersectsLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeogIntersectsLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeogIntersectsLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeogIntersectsLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeogDwithinPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeogDwithinPhysicalFunction.hpp new file mode 100644 index 0000000000..20e604f0e3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeogDwithinPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeogDwithinPhysicalFunction : public PhysicalFunctionConcept { +public: + GeogDwithinPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2, PhysicalFunction tolerance); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeogIntersectsPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeogIntersectsPhysicalFunction.hpp new file mode 100644 index 0000000000..5e81e97871 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeogIntersectsPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeogIntersectsPhysicalFunction : public PhysicalFunctionConcept { +public: + GeogIntersectsPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index f955b87a94..3ff0225659 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -315,6 +315,8 @@ add_plugin(EverEqTgeoGeo PhysicalFunction nes-physical-operators EverEqTgeoGeoPh add_plugin(EverNeTgeoGeo PhysicalFunction nes-physical-operators EverNeTgeoGeoPhysicalFunction.cpp) add_plugin(AlwaysEqTgeoGeo PhysicalFunction nes-physical-operators AlwaysEqTgeoGeoPhysicalFunction.cpp) add_plugin(AlwaysNeTgeoGeo PhysicalFunction nes-physical-operators AlwaysNeTgeoGeoPhysicalFunction.cpp) +add_plugin(GeogIntersects PhysicalFunction nes-physical-operators GeogIntersectsPhysicalFunction.cpp) +add_plugin(GeogDwithin PhysicalFunction nes-physical-operators GeogDwithinPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/GeogDwithinPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeogDwithinPhysicalFunction.cpp new file mode 100644 index 0000000000..733ed8129d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeogDwithinPhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeogDwithinPhysicalFunction::GeogDwithinPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2, + PhysicalFunction tolerance) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); + paramFns.push_back(std::move(tolerance)); +} + +VarVal GeogDwithinPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto s1 = paramFns[0].execute(record, arena).cast(); + auto s2 = paramFns[1].execute(record, arena).cast(); + auto tol = paramFns[2].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, + const char* w2, uint32_t w2sz, + double tol) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + std::string s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + double r = geog_dwithin(gs1, gs2, tol, true) ? 1.0 : 0.0; + free(gs1); free(gs2); + return r; + } catch (const std::exception&) { return 0.0; } + }, + s1, s2, tol); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeogDwithinPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "GeogDwithinPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return GeogDwithinPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeogIntersectsPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeogIntersectsPhysicalFunction.cpp new file mode 100644 index 0000000000..868260650b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeogIntersectsPhysicalFunction.cpp @@ -0,0 +1,78 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeogIntersectsPhysicalFunction::GeogIntersectsPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); +} + +VarVal GeogIntersectsPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto s1 = paramFns[0].execute(record, arena).cast(); + auto s2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + std::string s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + double r = geog_intersects(gs1, gs2, true) ? 1.0 : 0.0; + free(gs1); free(gs2); + return r; + } catch (const std::exception&) { return 0.0; } + }, + s1, s2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeogIntersectsPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeogIntersectsPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeogIntersectsPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 4b5e7d3a75..a93e0c81c1 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -786,6 +786,8 @@ EVER_EQ_TGEO_GEO: 'EVER_EQ_TGEO_GEO' | 'ever_eq_tgeo_geo'; EVER_NE_TGEO_GEO: 'EVER_NE_TGEO_GEO' | 'ever_ne_tgeo_geo'; ALWAYS_EQ_TGEO_GEO: 'ALWAYS_EQ_TGEO_GEO' | 'always_eq_tgeo_geo'; ALWAYS_NE_TGEO_GEO: 'ALWAYS_NE_TGEO_GEO' | 'always_ne_tgeo_geo'; +GEOG_INTERSECTS: 'GEOG_INTERSECTS' | 'geog_intersects'; +GEOG_DWITHIN: 'GEOG_DWITHIN' | 'geog_dwithin'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index d8266caae0..a1546aaf35 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -367,6 +367,8 @@ #include #include #include +#include +#include #include #include #include @@ -9068,6 +9070,25 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(AlwaysNeTgeoGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); } /* END CODEGEN PARSER GLUE: ALWAYS_NE_TGEO_GEO */ + case AntlrSQLParser::GEOG_INTERSECTS: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeogIntersects requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeogIntersectsLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOG_INTERSECTS */ + case AntlrSQLParser::GEOG_DWITHIN: { + PRECONDITION(ctx->functionParam().size() == 3, + "GeogDwithin requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(GeogDwithinLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: GEOG_DWITHIN */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From cdc91c0b8d1a305d493af1dd9600d8234f48a444 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 00:13:39 +0200 Subject: [PATCH 57/86] feat(meos): add GEOM_INTERSECTS, GEOM_DWITHIN, ACOVERS_GEO_TGEO NES operators (W109) Wires geom_intersects(wkt1,wkt2) as a 2-arg planar predicate, geom_dwithin(wkt1,wkt2,tol) as a 3-arg planar within-distance predicate, and acovers_geo_tgeo(wkt,lon,lat,ts) as a 4-arg reversed-arg always-covers predicate (static geometry first in C call: gs, tgeo). --- .../Meos/AcoversGeoTgeoLogicalFunction.hpp | 51 +++++++++ .../Meos/GeomDwithinLogicalFunction.hpp | 50 ++++++++ .../Meos/GeomIntersectsLogicalFunction.hpp | 50 ++++++++ .../Meos/AcoversGeoTgeoLogicalFunction.cpp | 107 ++++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../Meos/GeomDwithinLogicalFunction.cpp | 103 +++++++++++++++++ .../Meos/GeomIntersectsLogicalFunction.cpp | 98 ++++++++++++++++ .../Meos/AcoversGeoTgeoPhysicalFunction.hpp | 35 ++++++ .../Meos/GeomDwithinPhysicalFunction.hpp | 34 ++++++ .../Meos/GeomIntersectsPhysicalFunction.hpp | 34 ++++++ .../Meos/AcoversGeoTgeoPhysicalFunction.cpp | 87 ++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../Meos/GeomDwithinPhysicalFunction.cpp | 84 ++++++++++++++ .../Meos/GeomIntersectsPhysicalFunction.cpp | 78 +++++++++++++ nes-sql-parser/AntlrSQL.g4 | 5 +- .../src/AntlrSQLQueryPlanCreator.cpp | 33 ++++++ 16 files changed, 854 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AcoversGeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomDwithinLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomIntersectsLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AcoversGeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomDwithinLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomIntersectsLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AcoversGeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomDwithinPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomIntersectsPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AcoversGeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomDwithinPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomIntersectsPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AcoversGeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AcoversGeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..f2d450898f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AcoversGeoTgeoLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the static geometry always covers the temporal geometry instant. + * + * Args: (wkt:VARCHAR, lon:FLOAT64, lat:FLOAT64, ts:UINT64) -> FLOAT64. + */ +class AcoversGeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AcoversGeoTgeo"; + + AcoversGeoTgeoLogicalFunction(LogicalFunction wkt, LogicalFunction lon, + LogicalFunction lat, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomDwithinLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomDwithinLogicalFunction.hpp new file mode 100644 index 0000000000..b80ca3ebfe --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomDwithinLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if two planar geometries are within tolerance distance (default planar). + * + * Args: (wkt1:VARCHAR, wkt2:VARCHAR, tolerance:FLOAT64) -> FLOAT64. + */ +class GeomDwithinLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomDwithin"; + + GeomDwithinLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2, LogicalFunction tolerance); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomIntersectsLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomIntersectsLogicalFunction.hpp new file mode 100644 index 0000000000..807ff15884 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomIntersectsLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if two planar geometries intersect (default planar, no dimension suffix). + * + * Args: (wkt1:VARCHAR, wkt2:VARCHAR) -> FLOAT64. + */ +class GeomIntersectsLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomIntersects"; + + GeomIntersectsLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AcoversGeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AcoversGeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..593968654e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AcoversGeoTgeoLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AcoversGeoTgeoLogicalFunction::AcoversGeoTgeoLogicalFunction(LogicalFunction wkt, LogicalFunction lon, + LogicalFunction lat, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(ts)); +} + +DataType AcoversGeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AcoversGeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AcoversGeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AcoversGeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "AcoversGeoTgeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AcoversGeoTgeoLogicalFunction::getType() const { return NAME; } + +bool AcoversGeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AcoversGeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AcoversGeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction AcoversGeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAcoversGeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "AcoversGeoTgeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return AcoversGeoTgeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 5df38df64e..7ab0bef4db 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -318,6 +318,9 @@ add_plugin(AlwaysEqTgeoGeo LogicalFunction nes-logical-operators AlwaysEqTgeoGeo add_plugin(AlwaysNeTgeoGeo LogicalFunction nes-logical-operators AlwaysNeTgeoGeoLogicalFunction.cpp) add_plugin(GeogIntersects LogicalFunction nes-logical-operators GeogIntersectsLogicalFunction.cpp) add_plugin(GeogDwithin LogicalFunction nes-logical-operators GeogDwithinLogicalFunction.cpp) +add_plugin(GeomIntersects LogicalFunction nes-logical-operators GeomIntersectsLogicalFunction.cpp) +add_plugin(GeomDwithin LogicalFunction nes-logical-operators GeomDwithinLogicalFunction.cpp) +add_plugin(AcoversGeoTgeo LogicalFunction nes-logical-operators AcoversGeoTgeoLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeomDwithinLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomDwithinLogicalFunction.cpp new file mode 100644 index 0000000000..f803655d83 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomDwithinLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomDwithinLogicalFunction::GeomDwithinLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2, + LogicalFunction tolerance) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); + parameters.push_back(std::move(tolerance)); +} + +DataType GeomDwithinLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomDwithinLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomDwithinLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomDwithinLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "GeomDwithinLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomDwithinLogicalFunction::getType() const { return NAME; } + +bool GeomDwithinLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomDwithinLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomDwithinLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "tolerance must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction GeomDwithinLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomDwithinLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "GeomDwithinLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return GeomDwithinLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomIntersectsLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomIntersectsLogicalFunction.cpp new file mode 100644 index 0000000000..52412f137a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomIntersectsLogicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomIntersectsLogicalFunction::GeomIntersectsLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomIntersectsLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomIntersectsLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomIntersectsLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomIntersectsLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeomIntersectsLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomIntersectsLogicalFunction::getType() const { return NAME; } + +bool GeomIntersectsLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomIntersectsLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomIntersectsLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomIntersectsLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomIntersectsLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomIntersectsLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomIntersectsLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AcoversGeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AcoversGeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..ca766b04b8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AcoversGeoTgeoPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AcoversGeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AcoversGeoTgeoPhysicalFunction(PhysicalFunction wkt, PhysicalFunction lon, + PhysicalFunction lat, PhysicalFunction ts); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomDwithinPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomDwithinPhysicalFunction.hpp new file mode 100644 index 0000000000..75375972e6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomDwithinPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomDwithinPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomDwithinPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2, PhysicalFunction tolerance); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomIntersectsPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomIntersectsPhysicalFunction.hpp new file mode 100644 index 0000000000..9db923782d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomIntersectsPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomIntersectsPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomIntersectsPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AcoversGeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AcoversGeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..aa7789b812 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AcoversGeoTgeoPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AcoversGeoTgeoPhysicalFunction::AcoversGeoTgeoPhysicalFunction(PhysicalFunction wkt, PhysicalFunction lon, + PhysicalFunction lat, PhysicalFunction ts) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(ts)); +} + +VarVal AcoversGeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto lon = paramFns[1].execute(record, arena).cast(); + auto lat = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w, uint32_t wsz, + double lon, double lat, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wktStr(w, wsz); + GSERIALIZED* gs = geom_in(wktStr.c_str(), -1); + if (!gs) return 0.0; + std::string tgeoWkt = fmt::format("SRID=4326;POINT({},{})@{}", lon, lat, ts); + Temporal* tgeo = tgeompoint_in(tgeoWkt.c_str()); + if (!tgeo) { free(gs); return 0.0; } + int r = acovers_geo_tgeo(gs, tgeo); + free(gs); free(tgeo); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + wkt, lon, lat, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAcoversGeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "AcoversGeoTgeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return AcoversGeoTgeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 3ff0225659..d14175121c 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -317,6 +317,9 @@ add_plugin(AlwaysEqTgeoGeo PhysicalFunction nes-physical-operators AlwaysEqTgeoG add_plugin(AlwaysNeTgeoGeo PhysicalFunction nes-physical-operators AlwaysNeTgeoGeoPhysicalFunction.cpp) add_plugin(GeogIntersects PhysicalFunction nes-physical-operators GeogIntersectsPhysicalFunction.cpp) add_plugin(GeogDwithin PhysicalFunction nes-physical-operators GeogDwithinPhysicalFunction.cpp) +add_plugin(GeomIntersects PhysicalFunction nes-physical-operators GeomIntersectsPhysicalFunction.cpp) +add_plugin(GeomDwithin PhysicalFunction nes-physical-operators GeomDwithinPhysicalFunction.cpp) +add_plugin(AcoversGeoTgeo PhysicalFunction nes-physical-operators AcoversGeoTgeoPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/GeomDwithinPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomDwithinPhysicalFunction.cpp new file mode 100644 index 0000000000..c66c4affd1 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomDwithinPhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomDwithinPhysicalFunction::GeomDwithinPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2, + PhysicalFunction tolerance) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); + paramFns.push_back(std::move(tolerance)); +} + +VarVal GeomDwithinPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto s1 = paramFns[0].execute(record, arena).cast(); + auto s2 = paramFns[1].execute(record, arena).cast(); + auto tol = paramFns[2].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, + const char* w2, uint32_t w2sz, + double tol) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + std::string s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + double r = geom_dwithin(gs1, gs2, tol) ? 1.0 : 0.0; + free(gs1); free(gs2); + return r; + } catch (const std::exception&) { return 0.0; } + }, + s1, s2, tol); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomDwithinPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "GeomDwithinPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return GeomDwithinPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomIntersectsPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomIntersectsPhysicalFunction.cpp new file mode 100644 index 0000000000..7b4878ec95 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomIntersectsPhysicalFunction.cpp @@ -0,0 +1,78 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomIntersectsPhysicalFunction::GeomIntersectsPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); +} + +VarVal GeomIntersectsPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto s1 = paramFns[0].execute(record, arena).cast(); + auto s2 = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz); + std::string s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + double r = geom_intersects(gs1, gs2) ? 1.0 : 0.0; + free(gs1); free(gs2); + return r; + } catch (const std::exception&) { return 0.0; } + }, + s1, s2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomIntersectsPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomIntersectsPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomIntersectsPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index a93e0c81c1..1ca2663af6 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -788,6 +788,9 @@ ALWAYS_EQ_TGEO_GEO: 'ALWAYS_EQ_TGEO_GEO' | 'always_eq_tgeo_geo'; ALWAYS_NE_TGEO_GEO: 'ALWAYS_NE_TGEO_GEO' | 'always_ne_tgeo_geo'; GEOG_INTERSECTS: 'GEOG_INTERSECTS' | 'geog_intersects'; GEOG_DWITHIN: 'GEOG_DWITHIN' | 'geog_dwithin'; +ACOVERS_GEO_TGEO: 'ACOVERS_GEO_TGEO' | 'acovers_geo_tgeo'; +GEOM_INTERSECTS: 'GEOM_INTERSECTS' | 'geom_intersects'; +GEOM_DWITHIN: 'GEOM_DWITHIN' | 'geom_dwithin'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index a1546aaf35..5058b60865 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -369,6 +369,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -9089,6 +9092,36 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(GeogDwithinLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); } /* END CODEGEN PARSER GLUE: GEOG_DWITHIN */ + case AntlrSQLParser::GEOM_INTERSECTS: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomIntersects requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomIntersectsLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS */ + case AntlrSQLParser::GEOM_DWITHIN: { + PRECONDITION(ctx->functionParam().size() == 3, + "GeomDwithin requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(GeomDwithinLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: GEOM_DWITHIN */ + case AntlrSQLParser::ACOVERS_GEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "AcoversGeoTgeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(AcoversGeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: ACOVERS_GEO_TGEO */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 5f89570203f4761f039b9ebbe0e7588539f84b1e Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 00:33:33 +0200 Subject: [PATCH 58/86] feat(meos): add H3_GS_POINT_TO_CELL and EVER/ALWAYS_EQ/NE_TH3INDEX_H3INDEX NES operators (W110) Wires h3_gs_point_to_cell(lon,lat,resolution) as a 3-arg (FLOAT64, FLOAT64, UINT64) -> VARCHAR operator returning the H3 cell hex string, and ever_eq/ne + always_eq/ne_th3index_h3index as 3-arg (cell:UINT64, ts:UINT64, target:UINT64) -> FLOAT64 predicates backed by th3indexinst_make. --- ...AlwaysEqTh3indexH3indexLogicalFunction.hpp | 50 +++++++++ ...AlwaysNeTh3indexH3indexLogicalFunction.hpp | 50 +++++++++ .../EverEqTh3indexH3indexLogicalFunction.hpp | 50 +++++++++ .../EverNeTh3indexH3indexLogicalFunction.hpp | 50 +++++++++ .../Meos/H3GsPointToCellLogicalFunction.hpp | 50 +++++++++ ...AlwaysEqTh3indexH3indexLogicalFunction.cpp | 103 ++++++++++++++++++ ...AlwaysNeTh3indexH3indexLogicalFunction.cpp | 103 ++++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../EverEqTh3indexH3indexLogicalFunction.cpp | 103 ++++++++++++++++++ .../EverNeTh3indexH3indexLogicalFunction.cpp | 103 ++++++++++++++++++ .../Meos/H3GsPointToCellLogicalFunction.cpp | 103 ++++++++++++++++++ ...lwaysEqTh3indexH3indexPhysicalFunction.hpp | 34 ++++++ ...lwaysNeTh3indexH3indexPhysicalFunction.hpp | 34 ++++++ .../EverEqTh3indexH3indexPhysicalFunction.hpp | 34 ++++++ .../EverNeTh3indexH3indexPhysicalFunction.hpp | 34 ++++++ .../Meos/H3GsPointToCellPhysicalFunction.hpp | 34 ++++++ ...lwaysEqTh3indexH3indexPhysicalFunction.cpp | 76 +++++++++++++ ...lwaysNeTh3indexH3indexPhysicalFunction.cpp | 76 +++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../EverEqTh3indexH3indexPhysicalFunction.cpp | 76 +++++++++++++ .../EverNeTh3indexH3indexPhysicalFunction.cpp | 76 +++++++++++++ .../Meos/H3GsPointToCellPhysicalFunction.cpp | 91 ++++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 7 +- .../src/AntlrSQLQueryPlanCreator.cpp | 55 ++++++++++ 24 files changed, 1401 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTh3indexH3indexLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTh3indexH3indexLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTh3indexH3indexLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTh3indexH3indexLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/H3GsPointToCellLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTh3indexH3indexLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTh3indexH3indexLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTh3indexH3indexLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTh3indexH3indexLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/H3GsPointToCellLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTh3indexH3indexPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTh3indexH3indexPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTh3indexH3indexPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTh3indexH3indexPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/H3GsPointToCellPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTh3indexH3indexPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTh3indexH3indexPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTh3indexH3indexPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTh3indexH3indexPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/H3GsPointToCellPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTh3indexH3indexLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTh3indexH3indexLogicalFunction.hpp new file mode 100644 index 0000000000..d2c43b7f9f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTh3indexH3indexLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the th3index instant is always equal to the target H3 cell. + * + * Args: (cell:UINT64, ts:UINT64, target:UINT64) -> FLOAT64. + */ +class AlwaysEqTh3indexH3indexLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTh3indexH3index"; + + AlwaysEqTh3indexH3indexLogicalFunction(LogicalFunction cell, LogicalFunction ts, LogicalFunction target); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTh3indexH3indexLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTh3indexH3indexLogicalFunction.hpp new file mode 100644 index 0000000000..ed7fdd1e51 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTh3indexH3indexLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the th3index instant is always not equal to the target H3 cell. + * + * Args: (cell:UINT64, ts:UINT64, target:UINT64) -> FLOAT64. + */ +class AlwaysNeTh3indexH3indexLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTh3indexH3index"; + + AlwaysNeTh3indexH3indexLogicalFunction(LogicalFunction cell, LogicalFunction ts, LogicalFunction target); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTh3indexH3indexLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTh3indexH3indexLogicalFunction.hpp new file mode 100644 index 0000000000..8014b55647 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTh3indexH3indexLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the th3index instant is ever equal to the target H3 cell. + * + * Args: (cell:UINT64, ts:UINT64, target:UINT64) -> FLOAT64. + */ +class EverEqTh3indexH3indexLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTh3indexH3index"; + + EverEqTh3indexH3indexLogicalFunction(LogicalFunction cell, LogicalFunction ts, LogicalFunction target); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTh3indexH3indexLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTh3indexH3indexLogicalFunction.hpp new file mode 100644 index 0000000000..7bc68238bd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTh3indexH3indexLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the th3index instant is ever not equal to the target H3 cell. + * + * Args: (cell:UINT64, ts:UINT64, target:UINT64) -> FLOAT64. + */ +class EverNeTh3indexH3indexLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTh3indexH3index"; + + EverNeTh3indexH3indexLogicalFunction(LogicalFunction cell, LogicalFunction ts, LogicalFunction target); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/H3GsPointToCellLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/H3GsPointToCellLogicalFunction.hpp new file mode 100644 index 0000000000..ae077870fd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/H3GsPointToCellLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the H3 cell index (hex string) for a point at the given resolution. + * + * Args: (lon:FLOAT64, lat:FLOAT64, resolution:UINT64) -> VARCHAR. + */ +class H3GsPointToCellLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "H3GsPointToCell"; + + H3GsPointToCellLogicalFunction(LogicalFunction lon, LogicalFunction lat, LogicalFunction resolution); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTh3indexH3indexLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTh3indexH3indexLogicalFunction.cpp new file mode 100644 index 0000000000..e8fb5a8b8c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTh3indexH3indexLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTh3indexH3indexLogicalFunction::AlwaysEqTh3indexH3indexLogicalFunction(LogicalFunction cell, LogicalFunction ts, + LogicalFunction target) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(target)); +} + +DataType AlwaysEqTh3indexH3indexLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTh3indexH3indexLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTh3indexH3indexLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTh3indexH3indexLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "AlwaysEqTh3indexH3indexLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTh3indexH3indexLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTh3indexH3indexLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTh3indexH3indexLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqTh3indexH3indexLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "target must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysEqTh3indexH3indexLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTh3indexH3indexLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqTh3indexH3indexLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return AlwaysEqTh3indexH3indexLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTh3indexH3indexLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTh3indexH3indexLogicalFunction.cpp new file mode 100644 index 0000000000..0ad2ea86d5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTh3indexH3indexLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTh3indexH3indexLogicalFunction::AlwaysNeTh3indexH3indexLogicalFunction(LogicalFunction cell, LogicalFunction ts, + LogicalFunction target) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(target)); +} + +DataType AlwaysNeTh3indexH3indexLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTh3indexH3indexLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTh3indexH3indexLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTh3indexH3indexLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "AlwaysNeTh3indexH3indexLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTh3indexH3indexLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTh3indexH3indexLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTh3indexH3indexLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeTh3indexH3indexLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "target must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysNeTh3indexH3indexLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTh3indexH3indexLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeTh3indexH3indexLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return AlwaysNeTh3indexH3indexLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 7ab0bef4db..88413fc1bc 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -321,6 +321,11 @@ add_plugin(GeogDwithin LogicalFunction nes-logical-operators GeogDwithinLogicalF add_plugin(GeomIntersects LogicalFunction nes-logical-operators GeomIntersectsLogicalFunction.cpp) add_plugin(GeomDwithin LogicalFunction nes-logical-operators GeomDwithinLogicalFunction.cpp) add_plugin(AcoversGeoTgeo LogicalFunction nes-logical-operators AcoversGeoTgeoLogicalFunction.cpp) +add_plugin(H3GsPointToCell LogicalFunction nes-logical-operators H3GsPointToCellLogicalFunction.cpp) +add_plugin(EverEqTh3indexH3index LogicalFunction nes-logical-operators EverEqTh3indexH3indexLogicalFunction.cpp) +add_plugin(EverNeTh3indexH3index LogicalFunction nes-logical-operators EverNeTh3indexH3indexLogicalFunction.cpp) +add_plugin(AlwaysEqTh3indexH3index LogicalFunction nes-logical-operators AlwaysEqTh3indexH3indexLogicalFunction.cpp) +add_plugin(AlwaysNeTh3indexH3index LogicalFunction nes-logical-operators AlwaysNeTh3indexH3indexLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTh3indexH3indexLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTh3indexH3indexLogicalFunction.cpp new file mode 100644 index 0000000000..7c6aabf12e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTh3indexH3indexLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTh3indexH3indexLogicalFunction::EverEqTh3indexH3indexLogicalFunction(LogicalFunction cell, LogicalFunction ts, + LogicalFunction target) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(target)); +} + +DataType EverEqTh3indexH3indexLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTh3indexH3indexLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTh3indexH3indexLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTh3indexH3indexLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "EverEqTh3indexH3indexLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTh3indexH3indexLogicalFunction::getType() const { return NAME; } + +bool EverEqTh3indexH3indexLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTh3indexH3indexLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqTh3indexH3indexLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "target must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverEqTh3indexH3indexLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTh3indexH3indexLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqTh3indexH3indexLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return EverEqTh3indexH3indexLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTh3indexH3indexLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTh3indexH3indexLogicalFunction.cpp new file mode 100644 index 0000000000..cec911112c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTh3indexH3indexLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTh3indexH3indexLogicalFunction::EverNeTh3indexH3indexLogicalFunction(LogicalFunction cell, LogicalFunction ts, + LogicalFunction target) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(target)); +} + +DataType EverNeTh3indexH3indexLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTh3indexH3indexLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTh3indexH3indexLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTh3indexH3indexLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "EverNeTh3indexH3indexLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTh3indexH3indexLogicalFunction::getType() const { return NAME; } + +bool EverNeTh3indexH3indexLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTh3indexH3indexLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeTh3indexH3indexLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "target must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverNeTh3indexH3indexLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTh3indexH3indexLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeTh3indexH3indexLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return EverNeTh3indexH3indexLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/H3GsPointToCellLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/H3GsPointToCellLogicalFunction.cpp new file mode 100644 index 0000000000..054c766444 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/H3GsPointToCellLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +H3GsPointToCellLogicalFunction::H3GsPointToCellLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction resolution) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(3); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(resolution)); +} + +DataType H3GsPointToCellLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction H3GsPointToCellLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector H3GsPointToCellLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction H3GsPointToCellLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "H3GsPointToCellLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view H3GsPointToCellLogicalFunction::getType() const { return NAME; } + +bool H3GsPointToCellLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string H3GsPointToCellLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction H3GsPointToCellLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "resolution must be UINT64"); + return withChildren(c); +} + +SerializableFunction H3GsPointToCellLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterH3GsPointToCellLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "H3GsPointToCellLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return H3GsPointToCellLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTh3indexH3indexPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTh3indexH3indexPhysicalFunction.hpp new file mode 100644 index 0000000000..09e76ee3fe --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTh3indexH3indexPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTh3indexH3indexPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTh3indexH3indexPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, PhysicalFunction target); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTh3indexH3indexPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTh3indexH3indexPhysicalFunction.hpp new file mode 100644 index 0000000000..1c46209d5f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTh3indexH3indexPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTh3indexH3indexPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTh3indexH3indexPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, PhysicalFunction target); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTh3indexH3indexPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTh3indexH3indexPhysicalFunction.hpp new file mode 100644 index 0000000000..7d62fb93ff --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTh3indexH3indexPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTh3indexH3indexPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTh3indexH3indexPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, PhysicalFunction target); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTh3indexH3indexPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTh3indexH3indexPhysicalFunction.hpp new file mode 100644 index 0000000000..413bbf83b7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTh3indexH3indexPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTh3indexH3indexPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTh3indexH3indexPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, PhysicalFunction target); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/H3GsPointToCellPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/H3GsPointToCellPhysicalFunction.hpp new file mode 100644 index 0000000000..3410feb5e7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/H3GsPointToCellPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class H3GsPointToCellPhysicalFunction : public PhysicalFunctionConcept { +public: + H3GsPointToCellPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, PhysicalFunction resolution); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTh3indexH3indexPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTh3indexH3indexPhysicalFunction.cpp new file mode 100644 index 0000000000..567249216c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTh3indexH3indexPhysicalFunction.cpp @@ -0,0 +1,76 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTh3indexH3indexPhysicalFunction::AlwaysEqTh3indexH3indexPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, + PhysicalFunction target) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(target)); +} + +VarVal AlwaysEqTh3indexH3indexPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast(); + auto target = paramFns[2].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t cell, uint64_t ts, uint64_t target) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst = th3indexinst_make((H3Index)cell, (TimestampTz)ts); + if (!inst) return 0.0; + int r = always_eq_th3index_h3index(inst, (H3Index)target); + free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + cell, ts, target); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTh3indexH3indexPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqTh3indexH3indexPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTh3indexH3indexPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTh3indexH3indexPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTh3indexH3indexPhysicalFunction.cpp new file mode 100644 index 0000000000..ac819a26dd --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTh3indexH3indexPhysicalFunction.cpp @@ -0,0 +1,76 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTh3indexH3indexPhysicalFunction::AlwaysNeTh3indexH3indexPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, + PhysicalFunction target) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(target)); +} + +VarVal AlwaysNeTh3indexH3indexPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast(); + auto target = paramFns[2].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t cell, uint64_t ts, uint64_t target) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst = th3indexinst_make((H3Index)cell, (TimestampTz)ts); + if (!inst) return 0.0; + int r = always_ne_th3index_h3index(inst, (H3Index)target); + free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + cell, ts, target); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTh3indexH3indexPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeTh3indexH3indexPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTh3indexH3indexPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index d14175121c..50e4d63d19 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -320,6 +320,11 @@ add_plugin(GeogDwithin PhysicalFunction nes-physical-operators GeogDwithinPhysic add_plugin(GeomIntersects PhysicalFunction nes-physical-operators GeomIntersectsPhysicalFunction.cpp) add_plugin(GeomDwithin PhysicalFunction nes-physical-operators GeomDwithinPhysicalFunction.cpp) add_plugin(AcoversGeoTgeo PhysicalFunction nes-physical-operators AcoversGeoTgeoPhysicalFunction.cpp) +add_plugin(H3GsPointToCell PhysicalFunction nes-physical-operators H3GsPointToCellPhysicalFunction.cpp) +add_plugin(EverEqTh3indexH3index PhysicalFunction nes-physical-operators EverEqTh3indexH3indexPhysicalFunction.cpp) +add_plugin(EverNeTh3indexH3index PhysicalFunction nes-physical-operators EverNeTh3indexH3indexPhysicalFunction.cpp) +add_plugin(AlwaysEqTh3indexH3index PhysicalFunction nes-physical-operators AlwaysEqTh3indexH3indexPhysicalFunction.cpp) +add_plugin(AlwaysNeTh3indexH3index PhysicalFunction nes-physical-operators AlwaysNeTh3indexH3indexPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTh3indexH3indexPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTh3indexH3indexPhysicalFunction.cpp new file mode 100644 index 0000000000..a488198ce1 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTh3indexH3indexPhysicalFunction.cpp @@ -0,0 +1,76 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTh3indexH3indexPhysicalFunction::EverEqTh3indexH3indexPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, + PhysicalFunction target) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(target)); +} + +VarVal EverEqTh3indexH3indexPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast(); + auto target = paramFns[2].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t cell, uint64_t ts, uint64_t target) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst = th3indexinst_make((H3Index)cell, (TimestampTz)ts); + if (!inst) return 0.0; + int r = ever_eq_th3index_h3index(inst, (H3Index)target); + free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + cell, ts, target); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTh3indexH3indexPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqTh3indexH3indexPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverEqTh3indexH3indexPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTh3indexH3indexPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTh3indexH3indexPhysicalFunction.cpp new file mode 100644 index 0000000000..42ebd4deb8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTh3indexH3indexPhysicalFunction.cpp @@ -0,0 +1,76 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTh3indexH3indexPhysicalFunction::EverNeTh3indexH3indexPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, + PhysicalFunction target) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(target)); +} + +VarVal EverNeTh3indexH3indexPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast(); + auto target = paramFns[2].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t cell, uint64_t ts, uint64_t target) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst = th3indexinst_make((H3Index)cell, (TimestampTz)ts); + if (!inst) return 0.0; + int r = ever_ne_th3index_h3index(inst, (H3Index)target); + free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + cell, ts, target); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTh3indexH3indexPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeTh3indexH3indexPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverNeTh3indexH3indexPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/H3GsPointToCellPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/H3GsPointToCellPhysicalFunction.cpp new file mode 100644 index 0000000000..bebd4f0aa9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/H3GsPointToCellPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +H3GsPointToCellPhysicalFunction::H3GsPointToCellPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction resolution) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(resolution)); +} + +VarVal H3GsPointToCellPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto res = paramFns[2].execute(record, arena).cast(); + + constexpr uint32_t MAX_LEN = 32; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](double lon, double lat, uint64_t res, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt = fmt::format("SRID=4326;POINT({} {})", lon, lat); + GSERIALIZED* gs = geom_in(wkt.c_str(), -1); + if (!gs) return 0u; + H3Index cell = h3_gs_point_to_cell(gs, (int32_t)res); + free(gs); + if (cell == 0) return 0u; + char* hex = h3index_out(cell); + if (!hex) return 0u; + uint32_t len = static_cast(strlen(hex)); + if (len > bufMax) len = bufMax; + memcpy(buf, hex, len); + free(hex); + return len; + } catch (const std::exception&) { return 0u; } + }, + lon, lat, res, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterH3GsPointToCellPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "H3GsPointToCellPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return H3GsPointToCellPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 1ca2663af6..e0a41cfd0b 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -791,6 +791,11 @@ GEOG_DWITHIN: 'GEOG_DWITHIN' | 'geog_dwithin'; ACOVERS_GEO_TGEO: 'ACOVERS_GEO_TGEO' | 'acovers_geo_tgeo'; GEOM_INTERSECTS: 'GEOM_INTERSECTS' | 'geom_intersects'; GEOM_DWITHIN: 'GEOM_DWITHIN' | 'geom_dwithin'; +H3_GS_POINT_TO_CELL: 'H3_GS_POINT_TO_CELL' | 'h3_gs_point_to_cell'; +EVER_EQ_TH3INDEX_H3INDEX: 'EVER_EQ_TH3INDEX_H3INDEX' | 'ever_eq_th3index_h3index'; +EVER_NE_TH3INDEX_H3INDEX: 'EVER_NE_TH3INDEX_H3INDEX' | 'ever_ne_th3index_h3index'; +ALWAYS_EQ_TH3INDEX_H3INDEX: 'ALWAYS_EQ_TH3INDEX_H3INDEX' | 'always_eq_th3index_h3index'; +ALWAYS_NE_TH3INDEX_H3INDEX: 'ALWAYS_NE_TH3INDEX_H3INDEX' | 'always_ne_th3index_h3index'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 5058b60865..cc7f1e0fde 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -372,6 +372,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -9122,6 +9127,56 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(AcoversGeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); } /* END CODEGEN PARSER GLUE: ACOVERS_GEO_TGEO */ + case AntlrSQLParser::H3_GS_POINT_TO_CELL: { + PRECONDITION(ctx->functionParam().size() == 3, + "H3GsPointToCell requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(H3GsPointToCellLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: H3_GS_POINT_TO_CELL */ + case AntlrSQLParser::EVER_EQ_TH3INDEX_H3INDEX: { + PRECONDITION(ctx->functionParam().size() == 3, + "EverEqTh3indexH3index requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(EverEqTh3indexH3indexLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_TH3INDEX_H3INDEX */ + case AntlrSQLParser::EVER_NE_TH3INDEX_H3INDEX: { + PRECONDITION(ctx->functionParam().size() == 3, + "EverNeTh3indexH3index requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(EverNeTh3indexH3indexLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_TH3INDEX_H3INDEX */ + case AntlrSQLParser::ALWAYS_EQ_TH3INDEX_H3INDEX: { + PRECONDITION(ctx->functionParam().size() == 3, + "AlwaysEqTh3indexH3index requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(AlwaysEqTh3indexH3indexLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TH3INDEX_H3INDEX */ + case AntlrSQLParser::ALWAYS_NE_TH3INDEX_H3INDEX: { + PRECONDITION(ctx->functionParam().size() == 3, + "AlwaysNeTh3indexH3index requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(AlwaysNeTh3indexH3indexLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TH3INDEX_H3INDEX */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From b3743617bedc27dd01774ac6c560b088011e2818 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 01:42:04 +0200 Subject: [PATCH 59/86] feat(meos): add TH3INDEX hierarchy and property NES operators (W111) Wires nine th3index per-event operators across four patterns: TH3INDEX_GET_RESOLUTION/BASE_CELL_NUMBER/IS_VALID_CELL/IS_PENTAGON as 2-arg (cell:UINT64, ts:UINT64) -> FLOAT64; TH3INDEX_CELL_TO_PARENT_NEXT and TH3INDEX_CELL_TO_CENTER_CHILD_NEXT as 2-arg -> VARCHAR; TH3INDEX_CELL_TO_PARENT and TH3INDEX_CELL_TO_CENTER_CHILD as 3-arg (cell, ts, resolution) -> VARCHAR; and TH3INDEX_CELL_TO_CHILD_POS as 3-arg (cell, ts, parent_res) -> FLOAT64. --- ...3indexCellToCenterChildLogicalFunction.hpp | 50 +++++++++ ...exCellToCenterChildNextLogicalFunction.hpp | 50 +++++++++ .../Th3indexCellToChildPosLogicalFunction.hpp | 50 +++++++++ .../Th3indexCellToParentLogicalFunction.hpp | 50 +++++++++ ...h3indexCellToParentNextLogicalFunction.hpp | 50 +++++++++ ...3indexGetBaseCellNumberLogicalFunction.hpp | 50 +++++++++ .../Th3indexGetResolutionLogicalFunction.hpp | 50 +++++++++ .../Th3indexIsPentagonLogicalFunction.hpp | 50 +++++++++ .../Th3indexIsValidCellLogicalFunction.hpp | 50 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 9 ++ ...3indexCellToCenterChildLogicalFunction.cpp | 103 ++++++++++++++++++ ...exCellToCenterChildNextLogicalFunction.cpp | 98 +++++++++++++++++ .../Th3indexCellToChildPosLogicalFunction.cpp | 103 ++++++++++++++++++ .../Th3indexCellToParentLogicalFunction.cpp | 103 ++++++++++++++++++ ...h3indexCellToParentNextLogicalFunction.cpp | 98 +++++++++++++++++ ...3indexGetBaseCellNumberLogicalFunction.cpp | 98 +++++++++++++++++ .../Th3indexGetResolutionLogicalFunction.cpp | 98 +++++++++++++++++ .../Th3indexIsPentagonLogicalFunction.cpp | 98 +++++++++++++++++ .../Th3indexIsValidCellLogicalFunction.cpp | 98 +++++++++++++++++ ...xCellToCenterChildNextPhysicalFunction.hpp | 34 ++++++ ...indexCellToCenterChildPhysicalFunction.hpp | 34 ++++++ ...Th3indexCellToChildPosPhysicalFunction.hpp | 34 ++++++ ...3indexCellToParentNextPhysicalFunction.hpp | 34 ++++++ .../Th3indexCellToParentPhysicalFunction.hpp | 34 ++++++ ...indexGetBaseCellNumberPhysicalFunction.hpp | 34 ++++++ .../Th3indexGetResolutionPhysicalFunction.hpp | 34 ++++++ .../Th3indexIsPentagonPhysicalFunction.hpp | 34 ++++++ .../Th3indexIsValidCellPhysicalFunction.hpp | 34 ++++++ .../src/Functions/Meos/CMakeLists.txt | 9 ++ ...xCellToCenterChildNextPhysicalFunction.cpp | 87 +++++++++++++++ ...indexCellToCenterChildPhysicalFunction.cpp | 91 ++++++++++++++++ ...Th3indexCellToChildPosPhysicalFunction.cpp | 79 ++++++++++++++ ...3indexCellToParentNextPhysicalFunction.cpp | 87 +++++++++++++++ .../Th3indexCellToParentPhysicalFunction.cpp | 91 ++++++++++++++++ ...indexGetBaseCellNumberPhysicalFunction.cpp | 75 +++++++++++++ .../Th3indexGetResolutionPhysicalFunction.cpp | 75 +++++++++++++ .../Th3indexIsPentagonPhysicalFunction.cpp | 75 +++++++++++++ .../Th3indexIsValidCellPhysicalFunction.cpp | 75 +++++++++++++ nes-sql-parser/AntlrSQL.g4 | 11 +- .../src/AntlrSQLQueryPlanCreator.cpp | 93 ++++++++++++++++ 40 files changed, 2509 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/Th3indexCellToCenterChildLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/Th3indexCellToCenterChildNextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/Th3indexCellToChildPosLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/Th3indexCellToParentLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/Th3indexCellToParentNextLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/Th3indexGetBaseCellNumberLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/Th3indexGetResolutionLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/Th3indexIsPentagonLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/Th3indexIsValidCellLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/Th3indexCellToCenterChildLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/Th3indexCellToCenterChildNextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/Th3indexCellToChildPosLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/Th3indexCellToParentLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/Th3indexCellToParentNextLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/Th3indexGetBaseCellNumberLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/Th3indexGetResolutionLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/Th3indexIsPentagonLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/Th3indexIsValidCellLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/Th3indexCellToCenterChildNextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/Th3indexCellToCenterChildPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/Th3indexCellToChildPosPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/Th3indexCellToParentNextPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/Th3indexCellToParentPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/Th3indexGetBaseCellNumberPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/Th3indexGetResolutionPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/Th3indexIsPentagonPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/Th3indexIsValidCellPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/Th3indexCellToCenterChildNextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/Th3indexCellToCenterChildPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/Th3indexCellToChildPosPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/Th3indexCellToParentNextPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/Th3indexCellToParentPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/Th3indexGetBaseCellNumberPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/Th3indexGetResolutionPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/Th3indexIsPentagonPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/Th3indexIsValidCellPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/Th3indexCellToCenterChildLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/Th3indexCellToCenterChildLogicalFunction.hpp new file mode 100644 index 0000000000..7f91065322 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/Th3indexCellToCenterChildLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the H3 center child cell at the given resolution as a hex string. + * + * Args: (cell:UINT64, ts:UINT64, resolution:UINT64) -> VARCHAR. + */ +class Th3indexCellToCenterChildLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "Th3indexCellToCenterChild"; + + Th3indexCellToCenterChildLogicalFunction(LogicalFunction cell, LogicalFunction ts, LogicalFunction resolution); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/Th3indexCellToCenterChildNextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/Th3indexCellToCenterChildNextLogicalFunction.hpp new file mode 100644 index 0000000000..5edb86a69b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/Th3indexCellToCenterChildNextLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the H3 center child cell at resolution+1 as a hex string. + * + * Args: (cell:UINT64, ts:UINT64) -> VARCHAR. + */ +class Th3indexCellToCenterChildNextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "Th3indexCellToCenterChildNext"; + + Th3indexCellToCenterChildNextLogicalFunction(LogicalFunction cell, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/Th3indexCellToChildPosLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/Th3indexCellToChildPosLogicalFunction.hpp new file mode 100644 index 0000000000..1ef6e8e7b4 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/Th3indexCellToChildPosLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the position of the H3 cell within its parent at parent_res as FLOAT64. + * + * Args: (cell:UINT64, ts:UINT64, parent_res:UINT64) -> FLOAT64. + */ +class Th3indexCellToChildPosLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "Th3indexCellToChildPos"; + + Th3indexCellToChildPosLogicalFunction(LogicalFunction cell, LogicalFunction ts, LogicalFunction parent_res); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/Th3indexCellToParentLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/Th3indexCellToParentLogicalFunction.hpp new file mode 100644 index 0000000000..e8f775f544 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/Th3indexCellToParentLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the H3 parent cell at the given resolution as a hex string. + * + * Args: (cell:UINT64, ts:UINT64, resolution:UINT64) -> VARCHAR. + */ +class Th3indexCellToParentLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "Th3indexCellToParent"; + + Th3indexCellToParentLogicalFunction(LogicalFunction cell, LogicalFunction ts, LogicalFunction resolution); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/Th3indexCellToParentNextLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/Th3indexCellToParentNextLogicalFunction.hpp new file mode 100644 index 0000000000..54df43c800 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/Th3indexCellToParentNextLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the H3 parent cell at resolution-1 as a hex string. + * + * Args: (cell:UINT64, ts:UINT64) -> VARCHAR. + */ +class Th3indexCellToParentNextLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "Th3indexCellToParentNext"; + + Th3indexCellToParentNextLogicalFunction(LogicalFunction cell, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/Th3indexGetBaseCellNumberLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/Th3indexGetBaseCellNumberLogicalFunction.hpp new file mode 100644 index 0000000000..8187544475 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/Th3indexGetBaseCellNumberLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the H3 base cell number (0-121) of the cell as FLOAT64. + * + * Args: (cell:UINT64, ts:UINT64) -> FLOAT64. + */ +class Th3indexGetBaseCellNumberLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "Th3indexGetBaseCellNumber"; + + Th3indexGetBaseCellNumberLogicalFunction(LogicalFunction cell, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/Th3indexGetResolutionLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/Th3indexGetResolutionLogicalFunction.hpp new file mode 100644 index 0000000000..d034651307 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/Th3indexGetResolutionLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the H3 resolution (0-15) of the cell as FLOAT64. + * + * Args: (cell:UINT64, ts:UINT64) -> FLOAT64. + */ +class Th3indexGetResolutionLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "Th3indexGetResolution"; + + Th3indexGetResolutionLogicalFunction(LogicalFunction cell, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/Th3indexIsPentagonLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/Th3indexIsPentagonLogicalFunction.hpp new file mode 100644 index 0000000000..60d583d8f2 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/Th3indexIsPentagonLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the H3 cell is a pentagon cell, 0.0 otherwise. + * + * Args: (cell:UINT64, ts:UINT64) -> FLOAT64. + */ +class Th3indexIsPentagonLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "Th3indexIsPentagon"; + + Th3indexIsPentagonLogicalFunction(LogicalFunction cell, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/Th3indexIsValidCellLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/Th3indexIsValidCellLogicalFunction.hpp new file mode 100644 index 0000000000..8a8d12f282 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/Th3indexIsValidCellLogicalFunction.hpp @@ -0,0 +1,50 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the H3 cell index is valid, 0.0 otherwise. + * + * Args: (cell:UINT64, ts:UINT64) -> FLOAT64. + */ +class Th3indexIsValidCellLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "Th3indexIsValidCell"; + + Th3indexIsValidCellLogicalFunction(LogicalFunction cell, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 88413fc1bc..3695594581 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -326,6 +326,15 @@ add_plugin(EverEqTh3indexH3index LogicalFunction nes-logical-operators EverEqTh3 add_plugin(EverNeTh3indexH3index LogicalFunction nes-logical-operators EverNeTh3indexH3indexLogicalFunction.cpp) add_plugin(AlwaysEqTh3indexH3index LogicalFunction nes-logical-operators AlwaysEqTh3indexH3indexLogicalFunction.cpp) add_plugin(AlwaysNeTh3indexH3index LogicalFunction nes-logical-operators AlwaysNeTh3indexH3indexLogicalFunction.cpp) +add_plugin(Th3indexGetResolution LogicalFunction nes-logical-operators Th3indexGetResolutionLogicalFunction.cpp) +add_plugin(Th3indexGetBaseCellNumber LogicalFunction nes-logical-operators Th3indexGetBaseCellNumberLogicalFunction.cpp) +add_plugin(Th3indexIsValidCell LogicalFunction nes-logical-operators Th3indexIsValidCellLogicalFunction.cpp) +add_plugin(Th3indexIsPentagon LogicalFunction nes-logical-operators Th3indexIsPentagonLogicalFunction.cpp) +add_plugin(Th3indexCellToParentNext LogicalFunction nes-logical-operators Th3indexCellToParentNextLogicalFunction.cpp) +add_plugin(Th3indexCellToCenterChildNext LogicalFunction nes-logical-operators Th3indexCellToCenterChildNextLogicalFunction.cpp) +add_plugin(Th3indexCellToParent LogicalFunction nes-logical-operators Th3indexCellToParentLogicalFunction.cpp) +add_plugin(Th3indexCellToCenterChild LogicalFunction nes-logical-operators Th3indexCellToCenterChildLogicalFunction.cpp) +add_plugin(Th3indexCellToChildPos LogicalFunction nes-logical-operators Th3indexCellToChildPosLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/Th3indexCellToCenterChildLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/Th3indexCellToCenterChildLogicalFunction.cpp new file mode 100644 index 0000000000..1b23759a61 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/Th3indexCellToCenterChildLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +Th3indexCellToCenterChildLogicalFunction::Th3indexCellToCenterChildLogicalFunction(LogicalFunction cell, LogicalFunction ts, + LogicalFunction resolution) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(3); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(resolution)); +} + +DataType Th3indexCellToCenterChildLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction Th3indexCellToCenterChildLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector Th3indexCellToCenterChildLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction Th3indexCellToCenterChildLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "Th3indexCellToCenterChildLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view Th3indexCellToCenterChildLogicalFunction::getType() const { return NAME; } + +bool Th3indexCellToCenterChildLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string Th3indexCellToCenterChildLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction Th3indexCellToCenterChildLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "resolution must be UINT64"); + return withChildren(c); +} + +SerializableFunction Th3indexCellToCenterChildLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTh3indexCellToCenterChildLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "Th3indexCellToCenterChildLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return Th3indexCellToCenterChildLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/Th3indexCellToCenterChildNextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/Th3indexCellToCenterChildNextLogicalFunction.cpp new file mode 100644 index 0000000000..8bb6a4bfcf --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/Th3indexCellToCenterChildNextLogicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +Th3indexCellToCenterChildNextLogicalFunction::Th3indexCellToCenterChildNextLogicalFunction(LogicalFunction cell, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(ts)); +} + +DataType Th3indexCellToCenterChildNextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction Th3indexCellToCenterChildNextLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector Th3indexCellToCenterChildNextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction Th3indexCellToCenterChildNextLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "Th3indexCellToCenterChildNextLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view Th3indexCellToCenterChildNextLogicalFunction::getType() const { return NAME; } + +bool Th3indexCellToCenterChildNextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string Th3indexCellToCenterChildNextLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction Th3indexCellToCenterChildNextLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction Th3indexCellToCenterChildNextLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTh3indexCellToCenterChildNextLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "Th3indexCellToCenterChildNextLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return Th3indexCellToCenterChildNextLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/Th3indexCellToChildPosLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/Th3indexCellToChildPosLogicalFunction.cpp new file mode 100644 index 0000000000..0c673ff91e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/Th3indexCellToChildPosLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +Th3indexCellToChildPosLogicalFunction::Th3indexCellToChildPosLogicalFunction(LogicalFunction cell, LogicalFunction ts, + LogicalFunction parent_res) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(parent_res)); +} + +DataType Th3indexCellToChildPosLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction Th3indexCellToChildPosLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector Th3indexCellToChildPosLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction Th3indexCellToChildPosLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "Th3indexCellToChildPosLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view Th3indexCellToChildPosLogicalFunction::getType() const { return NAME; } + +bool Th3indexCellToChildPosLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string Th3indexCellToChildPosLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction Th3indexCellToChildPosLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "parent_res must be UINT64"); + return withChildren(c); +} + +SerializableFunction Th3indexCellToChildPosLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTh3indexCellToChildPosLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "Th3indexCellToChildPosLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return Th3indexCellToChildPosLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/Th3indexCellToParentLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/Th3indexCellToParentLogicalFunction.cpp new file mode 100644 index 0000000000..0ae233f25a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/Th3indexCellToParentLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +Th3indexCellToParentLogicalFunction::Th3indexCellToParentLogicalFunction(LogicalFunction cell, LogicalFunction ts, + LogicalFunction resolution) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(3); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(resolution)); +} + +DataType Th3indexCellToParentLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction Th3indexCellToParentLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector Th3indexCellToParentLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction Th3indexCellToParentLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "Th3indexCellToParentLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view Th3indexCellToParentLogicalFunction::getType() const { return NAME; } + +bool Th3indexCellToParentLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string Th3indexCellToParentLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction Th3indexCellToParentLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "resolution must be UINT64"); + return withChildren(c); +} + +SerializableFunction Th3indexCellToParentLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTh3indexCellToParentLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "Th3indexCellToParentLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return Th3indexCellToParentLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/Th3indexCellToParentNextLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/Th3indexCellToParentNextLogicalFunction.cpp new file mode 100644 index 0000000000..4e975cb109 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/Th3indexCellToParentNextLogicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +Th3indexCellToParentNextLogicalFunction::Th3indexCellToParentNextLogicalFunction(LogicalFunction cell, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(ts)); +} + +DataType Th3indexCellToParentNextLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction Th3indexCellToParentNextLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector Th3indexCellToParentNextLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction Th3indexCellToParentNextLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "Th3indexCellToParentNextLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view Th3indexCellToParentNextLogicalFunction::getType() const { return NAME; } + +bool Th3indexCellToParentNextLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string Th3indexCellToParentNextLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction Th3indexCellToParentNextLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction Th3indexCellToParentNextLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTh3indexCellToParentNextLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "Th3indexCellToParentNextLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return Th3indexCellToParentNextLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/Th3indexGetBaseCellNumberLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/Th3indexGetBaseCellNumberLogicalFunction.cpp new file mode 100644 index 0000000000..5dee128ea8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/Th3indexGetBaseCellNumberLogicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +Th3indexGetBaseCellNumberLogicalFunction::Th3indexGetBaseCellNumberLogicalFunction(LogicalFunction cell, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(ts)); +} + +DataType Th3indexGetBaseCellNumberLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction Th3indexGetBaseCellNumberLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector Th3indexGetBaseCellNumberLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction Th3indexGetBaseCellNumberLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "Th3indexGetBaseCellNumberLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view Th3indexGetBaseCellNumberLogicalFunction::getType() const { return NAME; } + +bool Th3indexGetBaseCellNumberLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string Th3indexGetBaseCellNumberLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction Th3indexGetBaseCellNumberLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction Th3indexGetBaseCellNumberLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTh3indexGetBaseCellNumberLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "Th3indexGetBaseCellNumberLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return Th3indexGetBaseCellNumberLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/Th3indexGetResolutionLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/Th3indexGetResolutionLogicalFunction.cpp new file mode 100644 index 0000000000..300491aee2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/Th3indexGetResolutionLogicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +Th3indexGetResolutionLogicalFunction::Th3indexGetResolutionLogicalFunction(LogicalFunction cell, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(ts)); +} + +DataType Th3indexGetResolutionLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction Th3indexGetResolutionLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector Th3indexGetResolutionLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction Th3indexGetResolutionLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "Th3indexGetResolutionLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view Th3indexGetResolutionLogicalFunction::getType() const { return NAME; } + +bool Th3indexGetResolutionLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string Th3indexGetResolutionLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction Th3indexGetResolutionLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction Th3indexGetResolutionLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTh3indexGetResolutionLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "Th3indexGetResolutionLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return Th3indexGetResolutionLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/Th3indexIsPentagonLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/Th3indexIsPentagonLogicalFunction.cpp new file mode 100644 index 0000000000..ad627972b4 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/Th3indexIsPentagonLogicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +Th3indexIsPentagonLogicalFunction::Th3indexIsPentagonLogicalFunction(LogicalFunction cell, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(ts)); +} + +DataType Th3indexIsPentagonLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction Th3indexIsPentagonLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector Th3indexIsPentagonLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction Th3indexIsPentagonLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "Th3indexIsPentagonLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view Th3indexIsPentagonLogicalFunction::getType() const { return NAME; } + +bool Th3indexIsPentagonLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string Th3indexIsPentagonLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction Th3indexIsPentagonLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction Th3indexIsPentagonLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTh3indexIsPentagonLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "Th3indexIsPentagonLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return Th3indexIsPentagonLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/Th3indexIsValidCellLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/Th3indexIsValidCellLogicalFunction.cpp new file mode 100644 index 0000000000..9dc00f3032 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/Th3indexIsValidCellLogicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +Th3indexIsValidCellLogicalFunction::Th3indexIsValidCellLogicalFunction(LogicalFunction cell, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(ts)); +} + +DataType Th3indexIsValidCellLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction Th3indexIsValidCellLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector Th3indexIsValidCellLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction Th3indexIsValidCellLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "Th3indexIsValidCellLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view Th3indexIsValidCellLogicalFunction::getType() const { return NAME; } + +bool Th3indexIsValidCellLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string Th3indexIsValidCellLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction Th3indexIsValidCellLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction Th3indexIsValidCellLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTh3indexIsValidCellLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "Th3indexIsValidCellLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return Th3indexIsValidCellLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/Th3indexCellToCenterChildNextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/Th3indexCellToCenterChildNextPhysicalFunction.hpp new file mode 100644 index 0000000000..bdaa24c2b9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/Th3indexCellToCenterChildNextPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class Th3indexCellToCenterChildNextPhysicalFunction : public PhysicalFunctionConcept { +public: + Th3indexCellToCenterChildNextPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/Th3indexCellToCenterChildPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/Th3indexCellToCenterChildPhysicalFunction.hpp new file mode 100644 index 0000000000..6dd997905c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/Th3indexCellToCenterChildPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class Th3indexCellToCenterChildPhysicalFunction : public PhysicalFunctionConcept { +public: + Th3indexCellToCenterChildPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, PhysicalFunction resolution); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/Th3indexCellToChildPosPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/Th3indexCellToChildPosPhysicalFunction.hpp new file mode 100644 index 0000000000..ef0d4277c6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/Th3indexCellToChildPosPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class Th3indexCellToChildPosPhysicalFunction : public PhysicalFunctionConcept { +public: + Th3indexCellToChildPosPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, PhysicalFunction parent_res); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/Th3indexCellToParentNextPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/Th3indexCellToParentNextPhysicalFunction.hpp new file mode 100644 index 0000000000..89f54a3bd9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/Th3indexCellToParentNextPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class Th3indexCellToParentNextPhysicalFunction : public PhysicalFunctionConcept { +public: + Th3indexCellToParentNextPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/Th3indexCellToParentPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/Th3indexCellToParentPhysicalFunction.hpp new file mode 100644 index 0000000000..91630d0c57 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/Th3indexCellToParentPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class Th3indexCellToParentPhysicalFunction : public PhysicalFunctionConcept { +public: + Th3indexCellToParentPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, PhysicalFunction resolution); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/Th3indexGetBaseCellNumberPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/Th3indexGetBaseCellNumberPhysicalFunction.hpp new file mode 100644 index 0000000000..644d2b5e78 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/Th3indexGetBaseCellNumberPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class Th3indexGetBaseCellNumberPhysicalFunction : public PhysicalFunctionConcept { +public: + Th3indexGetBaseCellNumberPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/Th3indexGetResolutionPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/Th3indexGetResolutionPhysicalFunction.hpp new file mode 100644 index 0000000000..9595512c09 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/Th3indexGetResolutionPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class Th3indexGetResolutionPhysicalFunction : public PhysicalFunctionConcept { +public: + Th3indexGetResolutionPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/Th3indexIsPentagonPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/Th3indexIsPentagonPhysicalFunction.hpp new file mode 100644 index 0000000000..b174fd09fa --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/Th3indexIsPentagonPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class Th3indexIsPentagonPhysicalFunction : public PhysicalFunctionConcept { +public: + Th3indexIsPentagonPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/Th3indexIsValidCellPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/Th3indexIsValidCellPhysicalFunction.hpp new file mode 100644 index 0000000000..68f711e6b6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/Th3indexIsValidCellPhysicalFunction.hpp @@ -0,0 +1,34 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class Th3indexIsValidCellPhysicalFunction : public PhysicalFunctionConcept { +public: + Th3indexIsValidCellPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 50e4d63d19..9ea2261217 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -325,6 +325,15 @@ add_plugin(EverEqTh3indexH3index PhysicalFunction nes-physical-operators EverEqT add_plugin(EverNeTh3indexH3index PhysicalFunction nes-physical-operators EverNeTh3indexH3indexPhysicalFunction.cpp) add_plugin(AlwaysEqTh3indexH3index PhysicalFunction nes-physical-operators AlwaysEqTh3indexH3indexPhysicalFunction.cpp) add_plugin(AlwaysNeTh3indexH3index PhysicalFunction nes-physical-operators AlwaysNeTh3indexH3indexPhysicalFunction.cpp) +add_plugin(Th3indexGetResolution PhysicalFunction nes-physical-operators Th3indexGetResolutionPhysicalFunction.cpp) +add_plugin(Th3indexGetBaseCellNumber PhysicalFunction nes-physical-operators Th3indexGetBaseCellNumberPhysicalFunction.cpp) +add_plugin(Th3indexIsValidCell PhysicalFunction nes-physical-operators Th3indexIsValidCellPhysicalFunction.cpp) +add_plugin(Th3indexIsPentagon PhysicalFunction nes-physical-operators Th3indexIsPentagonPhysicalFunction.cpp) +add_plugin(Th3indexCellToParentNext PhysicalFunction nes-physical-operators Th3indexCellToParentNextPhysicalFunction.cpp) +add_plugin(Th3indexCellToCenterChildNext PhysicalFunction nes-physical-operators Th3indexCellToCenterChildNextPhysicalFunction.cpp) +add_plugin(Th3indexCellToParent PhysicalFunction nes-physical-operators Th3indexCellToParentPhysicalFunction.cpp) +add_plugin(Th3indexCellToCenterChild PhysicalFunction nes-physical-operators Th3indexCellToCenterChildPhysicalFunction.cpp) +add_plugin(Th3indexCellToChildPos PhysicalFunction nes-physical-operators Th3indexCellToChildPosPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/Th3indexCellToCenterChildNextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/Th3indexCellToCenterChildNextPhysicalFunction.cpp new file mode 100644 index 0000000000..716401e4b0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/Th3indexCellToCenterChildNextPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} +#include +#include + +namespace NES { + +Th3indexCellToCenterChildNextPhysicalFunction::Th3indexCellToCenterChildNextPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(ts)); +} + +VarVal Th3indexCellToCenterChildNextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast(); + + constexpr uint32_t MAX_LEN = 32; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](uint64_t cell, uint64_t ts, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst = th3indexinst_make((H3Index)cell, (TimestampTz)ts); + if (!inst) return 0u; + Temporal* res = th3index_cell_to_center_child_next(inst); + free(inst); + if (!res) return 0u; + H3Index result_cell = th3index_start_value(res); + free(res); + char* hex = h3index_out(result_cell); + if (!hex) return 0u; + uint32_t len = static_cast(strlen(hex)); + if (len > bufMax) len = bufMax; + memcpy(buf, hex, len); + free(hex); + return len; + } catch (const std::exception&) { return 0u; } + }, + cell, ts, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTh3indexCellToCenterChildNextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "Th3indexCellToCenterChildNextPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return Th3indexCellToCenterChildNextPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/Th3indexCellToCenterChildPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/Th3indexCellToCenterChildPhysicalFunction.cpp new file mode 100644 index 0000000000..b0d88b84c3 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/Th3indexCellToCenterChildPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} +#include +#include + +namespace NES { + +Th3indexCellToCenterChildPhysicalFunction::Th3indexCellToCenterChildPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, + PhysicalFunction resolution) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(resolution)); +} + +VarVal Th3indexCellToCenterChildPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast(); + auto resolution = paramFns[2].execute(record, arena).cast(); + + constexpr uint32_t MAX_LEN = 32; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](uint64_t cell, uint64_t ts, uint64_t resolution, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst = th3indexinst_make((H3Index)cell, (TimestampTz)ts); + if (!inst) return 0u; + Temporal* res = th3index_cell_to_center_child(inst, (int32_t)resolution); + free(inst); + if (!res) return 0u; + H3Index result_cell = th3index_start_value(res); + free(res); + char* hex = h3index_out(result_cell); + if (!hex) return 0u; + uint32_t len = static_cast(strlen(hex)); + if (len > bufMax) len = bufMax; + memcpy(buf, hex, len); + free(hex); + return len; + } catch (const std::exception&) { return 0u; } + }, + cell, ts, resolution, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTh3indexCellToCenterChildPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "Th3indexCellToCenterChildPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return Th3indexCellToCenterChildPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/Th3indexCellToChildPosPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/Th3indexCellToChildPosPhysicalFunction.cpp new file mode 100644 index 0000000000..ab53a9fb18 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/Th3indexCellToChildPosPhysicalFunction.cpp @@ -0,0 +1,79 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +Th3indexCellToChildPosPhysicalFunction::Th3indexCellToChildPosPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, + PhysicalFunction parent_res) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(parent_res)); +} + +VarVal Th3indexCellToChildPosPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast(); + auto parent_res = paramFns[2].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t cell, uint64_t ts, uint64_t parent_res) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst = th3indexinst_make((H3Index)cell, (TimestampTz)ts); + if (!inst) return 0.0; + Temporal* res = th3index_cell_to_child_pos(inst, (int32_t)parent_res); + free(inst); + if (!res) return 0.0; + double r = (double)tint_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + cell, ts, parent_res); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTh3indexCellToChildPosPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "Th3indexCellToChildPosPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return Th3indexCellToChildPosPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/Th3indexCellToParentNextPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/Th3indexCellToParentNextPhysicalFunction.cpp new file mode 100644 index 0000000000..53a04ef550 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/Th3indexCellToParentNextPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} +#include +#include + +namespace NES { + +Th3indexCellToParentNextPhysicalFunction::Th3indexCellToParentNextPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(ts)); +} + +VarVal Th3indexCellToParentNextPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast(); + + constexpr uint32_t MAX_LEN = 32; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](uint64_t cell, uint64_t ts, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst = th3indexinst_make((H3Index)cell, (TimestampTz)ts); + if (!inst) return 0u; + Temporal* res = th3index_cell_to_parent_next(inst); + free(inst); + if (!res) return 0u; + H3Index result_cell = th3index_start_value(res); + free(res); + char* hex = h3index_out(result_cell); + if (!hex) return 0u; + uint32_t len = static_cast(strlen(hex)); + if (len > bufMax) len = bufMax; + memcpy(buf, hex, len); + free(hex); + return len; + } catch (const std::exception&) { return 0u; } + }, + cell, ts, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTh3indexCellToParentNextPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "Th3indexCellToParentNextPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return Th3indexCellToParentNextPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/Th3indexCellToParentPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/Th3indexCellToParentPhysicalFunction.cpp new file mode 100644 index 0000000000..f991d67e81 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/Th3indexCellToParentPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} +#include +#include + +namespace NES { + +Th3indexCellToParentPhysicalFunction::Th3indexCellToParentPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts, + PhysicalFunction resolution) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(resolution)); +} + +VarVal Th3indexCellToParentPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast(); + auto resolution = paramFns[2].execute(record, arena).cast(); + + constexpr uint32_t MAX_LEN = 32; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](uint64_t cell, uint64_t ts, uint64_t resolution, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst = th3indexinst_make((H3Index)cell, (TimestampTz)ts); + if (!inst) return 0u; + Temporal* res = th3index_cell_to_parent(inst, (int32_t)resolution); + free(inst); + if (!res) return 0u; + H3Index result_cell = th3index_start_value(res); + free(res); + char* hex = h3index_out(result_cell); + if (!hex) return 0u; + uint32_t len = static_cast(strlen(hex)); + if (len > bufMax) len = bufMax; + memcpy(buf, hex, len); + free(hex); + return len; + } catch (const std::exception&) { return 0u; } + }, + cell, ts, resolution, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTh3indexCellToParentPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "Th3indexCellToParentPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return Th3indexCellToParentPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/Th3indexGetBaseCellNumberPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/Th3indexGetBaseCellNumberPhysicalFunction.cpp new file mode 100644 index 0000000000..2de1f4f7c2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/Th3indexGetBaseCellNumberPhysicalFunction.cpp @@ -0,0 +1,75 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +Th3indexGetBaseCellNumberPhysicalFunction::Th3indexGetBaseCellNumberPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(ts)); +} + +VarVal Th3indexGetBaseCellNumberPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t cell, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst = th3indexinst_make((H3Index)cell, (TimestampTz)ts); + if (!inst) return 0.0; + Temporal* res = th3index_get_base_cell_number(inst); + free(inst); + if (!res) return 0.0; + double r = (double)tint_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + cell, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTh3indexGetBaseCellNumberPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "Th3indexGetBaseCellNumberPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return Th3indexGetBaseCellNumberPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/Th3indexGetResolutionPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/Th3indexGetResolutionPhysicalFunction.cpp new file mode 100644 index 0000000000..87eb8b9a37 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/Th3indexGetResolutionPhysicalFunction.cpp @@ -0,0 +1,75 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +Th3indexGetResolutionPhysicalFunction::Th3indexGetResolutionPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(ts)); +} + +VarVal Th3indexGetResolutionPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t cell, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst = th3indexinst_make((H3Index)cell, (TimestampTz)ts); + if (!inst) return 0.0; + Temporal* res = th3index_get_resolution(inst); + free(inst); + if (!res) return 0.0; + double r = (double)tint_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + cell, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTh3indexGetResolutionPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "Th3indexGetResolutionPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return Th3indexGetResolutionPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/Th3indexIsPentagonPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/Th3indexIsPentagonPhysicalFunction.cpp new file mode 100644 index 0000000000..0b318b0b0f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/Th3indexIsPentagonPhysicalFunction.cpp @@ -0,0 +1,75 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +Th3indexIsPentagonPhysicalFunction::Th3indexIsPentagonPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(ts)); +} + +VarVal Th3indexIsPentagonPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t cell, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst = th3indexinst_make((H3Index)cell, (TimestampTz)ts); + if (!inst) return 0.0; + Temporal* res = th3index_is_pentagon(inst); + free(inst); + if (!res) return 0.0; + double r = tbool_start_value(res) ? 1.0 : 0.0; + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + cell, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTh3indexIsPentagonPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "Th3indexIsPentagonPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return Th3indexIsPentagonPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/Th3indexIsValidCellPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/Th3indexIsValidCellPhysicalFunction.cpp new file mode 100644 index 0000000000..5a435832c3 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/Th3indexIsValidCellPhysicalFunction.cpp @@ -0,0 +1,75 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +Th3indexIsValidCellPhysicalFunction::Th3indexIsValidCellPhysicalFunction(PhysicalFunction cell, PhysicalFunction ts) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(ts)); +} + +VarVal Th3indexIsValidCellPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto ts = paramFns[1].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t cell, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst = th3indexinst_make((H3Index)cell, (TimestampTz)ts); + if (!inst) return 0.0; + Temporal* res = th3index_is_valid_cell(inst); + free(inst); + if (!res) return 0.0; + double r = tbool_start_value(res) ? 1.0 : 0.0; + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + cell, ts); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTh3indexIsValidCellPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "Th3indexIsValidCellPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return Th3indexIsValidCellPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index e0a41cfd0b..9dfea8ea03 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -796,6 +796,15 @@ EVER_EQ_TH3INDEX_H3INDEX: 'EVER_EQ_TH3INDEX_H3INDEX' | 'ever_eq_th3index_h3index EVER_NE_TH3INDEX_H3INDEX: 'EVER_NE_TH3INDEX_H3INDEX' | 'ever_ne_th3index_h3index'; ALWAYS_EQ_TH3INDEX_H3INDEX: 'ALWAYS_EQ_TH3INDEX_H3INDEX' | 'always_eq_th3index_h3index'; ALWAYS_NE_TH3INDEX_H3INDEX: 'ALWAYS_NE_TH3INDEX_H3INDEX' | 'always_ne_th3index_h3index'; +TH3INDEX_GET_RESOLUTION: 'TH3INDEX_GET_RESOLUTION' | 'th3index_get_resolution'; +TH3INDEX_GET_BASE_CELL_NUMBER: 'TH3INDEX_GET_BASE_CELL_NUMBER' | 'th3index_get_base_cell_number'; +TH3INDEX_IS_VALID_CELL: 'TH3INDEX_IS_VALID_CELL' | 'th3index_is_valid_cell'; +TH3INDEX_IS_PENTAGON: 'TH3INDEX_IS_PENTAGON' | 'th3index_is_pentagon'; +TH3INDEX_CELL_TO_PARENT_NEXT: 'TH3INDEX_CELL_TO_PARENT_NEXT' | 'th3index_cell_to_parent_next'; +TH3INDEX_CELL_TO_CENTER_CHILD_NEXT: 'TH3INDEX_CELL_TO_CENTER_CHILD_NEXT' | 'th3index_cell_to_center_child_next'; +TH3INDEX_CELL_TO_PARENT: 'TH3INDEX_CELL_TO_PARENT' | 'th3index_cell_to_parent'; +TH3INDEX_CELL_TO_CENTER_CHILD: 'TH3INDEX_CELL_TO_CENTER_CHILD' | 'th3index_cell_to_center_child'; +TH3INDEX_CELL_TO_CHILD_POS: 'TH3INDEX_CELL_TO_CHILD_POS' | 'th3index_cell_to_child_pos'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index cc7f1e0fde..dc1c68f616 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -377,6 +377,15 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -9177,6 +9186,90 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(AlwaysNeTh3indexH3indexLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); } /* END CODEGEN PARSER GLUE: ALWAYS_NE_TH3INDEX_H3INDEX */ + case AntlrSQLParser::TH3INDEX_GET_RESOLUTION: { + PRECONDITION(ctx->functionParam().size() == 2, + "Th3indexGetResolution requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(Th3indexGetResolutionLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: TH3INDEX_GET_RESOLUTION */ + case AntlrSQLParser::TH3INDEX_GET_BASE_CELL_NUMBER: { + PRECONDITION(ctx->functionParam().size() == 2, + "Th3indexGetBaseCellNumber requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(Th3indexGetBaseCellNumberLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: TH3INDEX_GET_BASE_CELL_NUMBER */ + case AntlrSQLParser::TH3INDEX_IS_VALID_CELL: { + PRECONDITION(ctx->functionParam().size() == 2, + "Th3indexIsValidCell requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(Th3indexIsValidCellLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: TH3INDEX_IS_VALID_CELL */ + case AntlrSQLParser::TH3INDEX_IS_PENTAGON: { + PRECONDITION(ctx->functionParam().size() == 2, + "Th3indexIsPentagon requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(Th3indexIsPentagonLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: TH3INDEX_IS_PENTAGON */ + case AntlrSQLParser::TH3INDEX_CELL_TO_PARENT_NEXT: { + PRECONDITION(ctx->functionParam().size() == 2, + "Th3indexCellToParentNext requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(Th3indexCellToParentNextLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: TH3INDEX_CELL_TO_PARENT_NEXT */ + case AntlrSQLParser::TH3INDEX_CELL_TO_CENTER_CHILD_NEXT: { + PRECONDITION(ctx->functionParam().size() == 2, + "Th3indexCellToCenterChildNext requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(Th3indexCellToCenterChildNextLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: TH3INDEX_CELL_TO_CENTER_CHILD_NEXT */ + case AntlrSQLParser::TH3INDEX_CELL_TO_PARENT: { + PRECONDITION(ctx->functionParam().size() == 3, + "Th3indexCellToParent requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(Th3indexCellToParentLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: TH3INDEX_CELL_TO_PARENT */ + case AntlrSQLParser::TH3INDEX_CELL_TO_CENTER_CHILD: { + PRECONDITION(ctx->functionParam().size() == 3, + "Th3indexCellToCenterChild requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(Th3indexCellToCenterChildLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: TH3INDEX_CELL_TO_CENTER_CHILD */ + case AntlrSQLParser::TH3INDEX_CELL_TO_CHILD_POS: { + PRECONDITION(ctx->functionParam().size() == 3, + "Th3indexCellToChildPos requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(Th3indexCellToChildPosLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: TH3INDEX_CELL_TO_CHILD_POS */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From b838d48c7fa02809ffe1c7af4226bbefa69550c1 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 02:37:13 +0200 Subject: [PATCH 60/86] feat(meos): add TH3INDEX_ARE_NEIGHBOR_CELLS and TH3INDEX_GRID_DISTANCE NES operators (W112) Wires two binary th3index per-event operators using a new 4-arg pattern (cell1:UINT64, ts1:UINT64, cell2:UINT64, ts2:UINT64) -> FLOAT64: TH3INDEX_ARE_NEIGHBOR_CELLS returns 1.0 when two H3 cells share an edge, and TH3INDEX_GRID_DISTANCE returns the cell-grid distance between two H3 cells. Both build two th3index instants from the supplied cell+timestamp pairs and extract the scalar result from the Temporal* return. --- ...h3indexAreNeighborCellsLogicalFunction.hpp | 51 +++++++++ .../Th3indexGridDistanceLogicalFunction.hpp | 51 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + ...h3indexAreNeighborCellsLogicalFunction.cpp | 107 ++++++++++++++++++ .../Th3indexGridDistanceLogicalFunction.cpp | 107 ++++++++++++++++++ ...3indexAreNeighborCellsPhysicalFunction.hpp | 35 ++++++ .../Th3indexGridDistancePhysicalFunction.hpp | 35 ++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + ...3indexAreNeighborCellsPhysicalFunction.cpp | 85 ++++++++++++++ .../Th3indexGridDistancePhysicalFunction.cpp | 85 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 4 +- .../src/AntlrSQLQueryPlanCreator.cpp | 24 ++++ 12 files changed, 587 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/Th3indexAreNeighborCellsLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/Th3indexGridDistanceLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/Th3indexAreNeighborCellsLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/Th3indexGridDistanceLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/Th3indexAreNeighborCellsPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/Th3indexGridDistancePhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/Th3indexAreNeighborCellsPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/Th3indexGridDistancePhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/Th3indexAreNeighborCellsLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/Th3indexAreNeighborCellsLogicalFunction.hpp new file mode 100644 index 0000000000..532fce8853 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/Th3indexAreNeighborCellsLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two H3 cells are neighbors (share an edge), 0.0 otherwise. + * + * Args: (cell1:UINT64, ts1:UINT64, cell2:UINT64, ts2:UINT64) -> FLOAT64. + */ +class Th3indexAreNeighborCellsLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "Th3indexAreNeighborCells"; + + Th3indexAreNeighborCellsLogicalFunction(LogicalFunction cell1, LogicalFunction ts1, + LogicalFunction cell2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/Th3indexGridDistanceLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/Th3indexGridDistanceLogicalFunction.hpp new file mode 100644 index 0000000000..9e5a377e6e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/Th3indexGridDistanceLogicalFunction.hpp @@ -0,0 +1,51 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the H3 grid distance (number of cells) between two H3 cells as FLOAT64. + * + * Args: (cell1:UINT64, ts1:UINT64, cell2:UINT64, ts2:UINT64) -> FLOAT64. + */ +class Th3indexGridDistanceLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "Th3indexGridDistance"; + + Th3indexGridDistanceLogicalFunction(LogicalFunction cell1, LogicalFunction ts1, + LogicalFunction cell2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 3695594581..567fdce526 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -335,6 +335,8 @@ add_plugin(Th3indexCellToCenterChildNext LogicalFunction nes-logical-operators T add_plugin(Th3indexCellToParent LogicalFunction nes-logical-operators Th3indexCellToParentLogicalFunction.cpp) add_plugin(Th3indexCellToCenterChild LogicalFunction nes-logical-operators Th3indexCellToCenterChildLogicalFunction.cpp) add_plugin(Th3indexCellToChildPos LogicalFunction nes-logical-operators Th3indexCellToChildPosLogicalFunction.cpp) +add_plugin(Th3indexAreNeighborCells LogicalFunction nes-logical-operators Th3indexAreNeighborCellsLogicalFunction.cpp) +add_plugin(Th3indexGridDistance LogicalFunction nes-logical-operators Th3indexGridDistanceLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/Th3indexAreNeighborCellsLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/Th3indexAreNeighborCellsLogicalFunction.cpp new file mode 100644 index 0000000000..420cdbd9c6 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/Th3indexAreNeighborCellsLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +Th3indexAreNeighborCellsLogicalFunction::Th3indexAreNeighborCellsLogicalFunction(LogicalFunction cell1, LogicalFunction ts1, + LogicalFunction cell2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(cell1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(cell2)); + parameters.push_back(std::move(ts2)); +} + +DataType Th3indexAreNeighborCellsLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction Th3indexAreNeighborCellsLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector Th3indexAreNeighborCellsLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction Th3indexAreNeighborCellsLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "Th3indexAreNeighborCellsLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view Th3indexAreNeighborCellsLogicalFunction::getType() const { return NAME; } + +bool Th3indexAreNeighborCellsLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string Th3indexAreNeighborCellsLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction Th3indexAreNeighborCellsLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell1 must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "cell2 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction Th3indexAreNeighborCellsLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTh3indexAreNeighborCellsLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "Th3indexAreNeighborCellsLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return Th3indexAreNeighborCellsLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/Th3indexGridDistanceLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/Th3indexGridDistanceLogicalFunction.cpp new file mode 100644 index 0000000000..fbe6ca4117 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/Th3indexGridDistanceLogicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +Th3indexGridDistanceLogicalFunction::Th3indexGridDistanceLogicalFunction(LogicalFunction cell1, LogicalFunction ts1, + LogicalFunction cell2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(cell1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(cell2)); + parameters.push_back(std::move(ts2)); +} + +DataType Th3indexGridDistanceLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction Th3indexGridDistanceLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector Th3indexGridDistanceLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction Th3indexGridDistanceLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "Th3indexGridDistanceLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view Th3indexGridDistanceLogicalFunction::getType() const { return NAME; } + +bool Th3indexGridDistanceLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string Th3indexGridDistanceLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction Th3indexGridDistanceLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell1 must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "cell2 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction Th3indexGridDistanceLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterTh3indexGridDistanceLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "Th3indexGridDistanceLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return Th3indexGridDistanceLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/Th3indexAreNeighborCellsPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/Th3indexAreNeighborCellsPhysicalFunction.hpp new file mode 100644 index 0000000000..ef1ef99ec4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/Th3indexAreNeighborCellsPhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class Th3indexAreNeighborCellsPhysicalFunction : public PhysicalFunctionConcept { +public: + Th3indexAreNeighborCellsPhysicalFunction(PhysicalFunction cell1, PhysicalFunction ts1, + PhysicalFunction cell2, PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/Th3indexGridDistancePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/Th3indexGridDistancePhysicalFunction.hpp new file mode 100644 index 0000000000..a6064c1cdd --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/Th3indexGridDistancePhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class Th3indexGridDistancePhysicalFunction : public PhysicalFunctionConcept { +public: + Th3indexGridDistancePhysicalFunction(PhysicalFunction cell1, PhysicalFunction ts1, + PhysicalFunction cell2, PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 9ea2261217..1b3ab90e67 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -334,6 +334,8 @@ add_plugin(Th3indexCellToCenterChildNext PhysicalFunction nes-physical-operators add_plugin(Th3indexCellToParent PhysicalFunction nes-physical-operators Th3indexCellToParentPhysicalFunction.cpp) add_plugin(Th3indexCellToCenterChild PhysicalFunction nes-physical-operators Th3indexCellToCenterChildPhysicalFunction.cpp) add_plugin(Th3indexCellToChildPos PhysicalFunction nes-physical-operators Th3indexCellToChildPosPhysicalFunction.cpp) +add_plugin(Th3indexAreNeighborCells PhysicalFunction nes-physical-operators Th3indexAreNeighborCellsPhysicalFunction.cpp) +add_plugin(Th3indexGridDistance PhysicalFunction nes-physical-operators Th3indexGridDistancePhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/Th3indexAreNeighborCellsPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/Th3indexAreNeighborCellsPhysicalFunction.cpp new file mode 100644 index 0000000000..82d4b04de1 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/Th3indexAreNeighborCellsPhysicalFunction.cpp @@ -0,0 +1,85 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +Th3indexAreNeighborCellsPhysicalFunction::Th3indexAreNeighborCellsPhysicalFunction(PhysicalFunction cell1, PhysicalFunction ts1, + PhysicalFunction cell2, PhysicalFunction ts2) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(cell1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(cell2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal Th3indexAreNeighborCellsPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell1 = paramFns[0].execute(record, arena).cast(); + auto ts1 = paramFns[1].execute(record, arena).cast(); + auto cell2 = paramFns[2].execute(record, arena).cast(); + auto ts2 = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t cell1, uint64_t ts1, uint64_t cell2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst1 = th3indexinst_make((H3Index)cell1, (TimestampTz)ts1); + if (!inst1) return 0.0; + Temporal* inst2 = th3indexinst_make((H3Index)cell2, (TimestampTz)ts2); + if (!inst2) { free(inst1); return 0.0; } + Temporal* res = th3index_are_neighbor_cells(inst1, inst2); + free(inst1); + free(inst2); + if (!res) return 0.0; + double r = tbool_start_value(res) ? 1.0 : 0.0; + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + cell1, ts1, cell2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTh3indexAreNeighborCellsPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "Th3indexAreNeighborCellsPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return Th3indexAreNeighborCellsPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/Th3indexGridDistancePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/Th3indexGridDistancePhysicalFunction.cpp new file mode 100644 index 0000000000..daec755b58 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/Th3indexGridDistancePhysicalFunction.cpp @@ -0,0 +1,85 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +Th3indexGridDistancePhysicalFunction::Th3indexGridDistancePhysicalFunction(PhysicalFunction cell1, PhysicalFunction ts1, + PhysicalFunction cell2, PhysicalFunction ts2) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(cell1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(cell2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal Th3indexGridDistancePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell1 = paramFns[0].execute(record, arena).cast(); + auto ts1 = paramFns[1].execute(record, arena).cast(); + auto cell2 = paramFns[2].execute(record, arena).cast(); + auto ts2 = paramFns[3].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t cell1, uint64_t ts1, uint64_t cell2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Temporal* inst1 = th3indexinst_make((H3Index)cell1, (TimestampTz)ts1); + if (!inst1) return 0.0; + Temporal* inst2 = th3indexinst_make((H3Index)cell2, (TimestampTz)ts2); + if (!inst2) { free(inst1); return 0.0; } + Temporal* res = th3index_grid_distance(inst1, inst2); + free(inst1); + free(inst2); + if (!res) return 0.0; + double r = (double)tint_start_value(res); + free(res); + return r; + } catch (const std::exception&) { return 0.0; } + }, + cell1, ts1, cell2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterTh3indexGridDistancePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "Th3indexGridDistancePhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return Th3indexGridDistancePhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 9dfea8ea03..5a6e7111ec 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -805,6 +805,8 @@ TH3INDEX_CELL_TO_CENTER_CHILD_NEXT: 'TH3INDEX_CELL_TO_CENTER_CHILD_NEXT' | 'th3i TH3INDEX_CELL_TO_PARENT: 'TH3INDEX_CELL_TO_PARENT' | 'th3index_cell_to_parent'; TH3INDEX_CELL_TO_CENTER_CHILD: 'TH3INDEX_CELL_TO_CENTER_CHILD' | 'th3index_cell_to_center_child'; TH3INDEX_CELL_TO_CHILD_POS: 'TH3INDEX_CELL_TO_CHILD_POS' | 'th3index_cell_to_child_pos'; +TH3INDEX_ARE_NEIGHBOR_CELLS: 'TH3INDEX_ARE_NEIGHBOR_CELLS' | 'th3index_are_neighbor_cells'; +TH3INDEX_GRID_DISTANCE: 'TH3INDEX_GRID_DISTANCE' | 'th3index_grid_distance'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index dc1c68f616..364ad25082 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -386,6 +386,8 @@ #include #include #include +#include +#include #include #include #include @@ -9270,6 +9272,28 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(Th3indexCellToChildPosLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); } /* END CODEGEN PARSER GLUE: TH3INDEX_CELL_TO_CHILD_POS */ + case AntlrSQLParser::TH3INDEX_ARE_NEIGHBOR_CELLS: { + PRECONDITION(ctx->functionParam().size() == 4, + "Th3indexAreNeighborCells requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(Th3indexAreNeighborCellsLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: TH3INDEX_ARE_NEIGHBOR_CELLS */ + case AntlrSQLParser::TH3INDEX_GRID_DISTANCE: { + PRECONDITION(ctx->functionParam().size() == 4, + "Th3indexGridDistance requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(Th3indexGridDistanceLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: TH3INDEX_GRID_DISTANCE */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From a8de201009fc3684d04813b7c73a9582a10f5165 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 03:39:11 +0200 Subject: [PATCH 61/86] feat(meos): add tcbuffer_geo spatial predicate NES operators (W113) Wires eleven tcbuffer per-event spatial operators using a new 5-arg pattern (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. The physical functions build a tcbuffer instant from lon/lat/radius/ts via cbuffer_make + tcbufferinst_make, parse the target geometry from WKT, and call the MEOS predicate. Operators: EINTERSECTS/AINTERSECTS_TCBUFFER_GEO, ECOVERS/ACOVERS_TCBUFFER_GEO, EDISJOINT/ADISJOINT_TCBUFFER_GEO, ETOUCHES/ATOUCHES_TCBUFFER_GEO, ECONTAINS/ACONTAINS_TCBUFFER_GEO, NAD_TCBUFFER_GEO (returns distance as FLOAT64). --- .../AcontainsTcbufferGeoLogicalFunction.hpp | 52 +++++++ .../AcoversTcbufferGeoLogicalFunction.hpp | 52 +++++++ .../AdisjointTcbufferGeoLogicalFunction.hpp | 52 +++++++ .../AintersectsTcbufferGeoLogicalFunction.hpp | 52 +++++++ .../AtouchesTcbufferGeoLogicalFunction.hpp | 52 +++++++ .../EcontainsTcbufferGeoLogicalFunction.hpp | 52 +++++++ .../EcoversTcbufferGeoLogicalFunction.hpp | 52 +++++++ .../EdisjointTcbufferGeoLogicalFunction.hpp | 52 +++++++ .../EintersectsTcbufferGeoLogicalFunction.hpp | 52 +++++++ .../EtouchesTcbufferGeoLogicalFunction.hpp | 52 +++++++ .../Meos/NadTcbufferGeoLogicalFunction.hpp | 52 +++++++ .../AcontainsTcbufferGeoLogicalFunction.cpp | 112 ++++++++++++++ .../AcoversTcbufferGeoLogicalFunction.cpp | 112 ++++++++++++++ .../AdisjointTcbufferGeoLogicalFunction.cpp | 112 ++++++++++++++ .../AintersectsTcbufferGeoLogicalFunction.cpp | 112 ++++++++++++++ .../AtouchesTcbufferGeoLogicalFunction.cpp | 112 ++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 11 ++ .../EcontainsTcbufferGeoLogicalFunction.cpp | 112 ++++++++++++++ .../EcoversTcbufferGeoLogicalFunction.cpp | 112 ++++++++++++++ .../EdisjointTcbufferGeoLogicalFunction.cpp | 112 ++++++++++++++ .../EintersectsTcbufferGeoLogicalFunction.cpp | 112 ++++++++++++++ .../EtouchesTcbufferGeoLogicalFunction.cpp | 112 ++++++++++++++ .../Meos/NadTcbufferGeoLogicalFunction.cpp | 112 ++++++++++++++ .../AcontainsTcbufferGeoPhysicalFunction.hpp | 36 +++++ .../AcoversTcbufferGeoPhysicalFunction.hpp | 36 +++++ .../AdisjointTcbufferGeoPhysicalFunction.hpp | 36 +++++ ...AintersectsTcbufferGeoPhysicalFunction.hpp | 36 +++++ .../AtouchesTcbufferGeoPhysicalFunction.hpp | 36 +++++ .../EcontainsTcbufferGeoPhysicalFunction.hpp | 36 +++++ .../EcoversTcbufferGeoPhysicalFunction.hpp | 36 +++++ .../EdisjointTcbufferGeoPhysicalFunction.hpp | 36 +++++ ...EintersectsTcbufferGeoPhysicalFunction.hpp | 36 +++++ .../EtouchesTcbufferGeoPhysicalFunction.hpp | 36 +++++ .../Meos/NadTcbufferGeoPhysicalFunction.hpp | 36 +++++ .../AcontainsTcbufferGeoPhysicalFunction.cpp | 104 +++++++++++++ .../AcoversTcbufferGeoPhysicalFunction.cpp | 104 +++++++++++++ .../AdisjointTcbufferGeoPhysicalFunction.cpp | 104 +++++++++++++ ...AintersectsTcbufferGeoPhysicalFunction.cpp | 104 +++++++++++++ .../AtouchesTcbufferGeoPhysicalFunction.cpp | 104 +++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 11 ++ .../EcontainsTcbufferGeoPhysicalFunction.cpp | 104 +++++++++++++ .../EcoversTcbufferGeoPhysicalFunction.cpp | 104 +++++++++++++ .../EdisjointTcbufferGeoPhysicalFunction.cpp | 104 +++++++++++++ ...EintersectsTcbufferGeoPhysicalFunction.cpp | 104 +++++++++++++ .../EtouchesTcbufferGeoPhysicalFunction.cpp | 104 +++++++++++++ .../Meos/NadTcbufferGeoPhysicalFunction.cpp | 104 +++++++++++++ nes-sql-parser/AntlrSQL.g4 | 13 +- .../src/AntlrSQLQueryPlanCreator.cpp | 143 ++++++++++++++++++ 48 files changed, 3521 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AcontainsTcbufferGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AcoversTcbufferGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AdisjointTcbufferGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AintersectsTcbufferGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AtouchesTcbufferGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EcontainsTcbufferGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EcoversTcbufferGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EdisjointTcbufferGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EintersectsTcbufferGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EtouchesTcbufferGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/NadTcbufferGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AcontainsTcbufferGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AcoversTcbufferGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AdisjointTcbufferGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AintersectsTcbufferGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AtouchesTcbufferGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EcontainsTcbufferGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EcoversTcbufferGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EdisjointTcbufferGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EintersectsTcbufferGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EtouchesTcbufferGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/NadTcbufferGeoLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AcontainsTcbufferGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AcoversTcbufferGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AdisjointTcbufferGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AintersectsTcbufferGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AtouchesTcbufferGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EcontainsTcbufferGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EcoversTcbufferGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EdisjointTcbufferGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EintersectsTcbufferGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EtouchesTcbufferGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/NadTcbufferGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AcontainsTcbufferGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AcoversTcbufferGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AdisjointTcbufferGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AintersectsTcbufferGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AtouchesTcbufferGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EcontainsTcbufferGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EcoversTcbufferGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EdisjointTcbufferGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EintersectsTcbufferGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EtouchesTcbufferGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/NadTcbufferGeoPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AcontainsTcbufferGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AcontainsTcbufferGeoLogicalFunction.hpp new file mode 100644 index 0000000000..2ee87d957e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AcontainsTcbufferGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer always contains the static geometry, 0.0 otherwise. + * + * Args: (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class AcontainsTcbufferGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AcontainsTcbufferGeo"; + + AcontainsTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AcoversTcbufferGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AcoversTcbufferGeoLogicalFunction.hpp new file mode 100644 index 0000000000..e1f853661e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AcoversTcbufferGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer always covers the static geometry, 0.0 otherwise. + * + * Args: (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class AcoversTcbufferGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AcoversTcbufferGeo"; + + AcoversTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AdisjointTcbufferGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AdisjointTcbufferGeoLogicalFunction.hpp new file mode 100644 index 0000000000..6785185c3d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AdisjointTcbufferGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer is always disjoint from the static geometry, 0.0 otherwise. + * + * Args: (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class AdisjointTcbufferGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AdisjointTcbufferGeo"; + + AdisjointTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AintersectsTcbufferGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AintersectsTcbufferGeoLogicalFunction.hpp new file mode 100644 index 0000000000..7d8acc618a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AintersectsTcbufferGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer always intersects the static geometry, 0.0 otherwise. + * + * Args: (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class AintersectsTcbufferGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AintersectsTcbufferGeo"; + + AintersectsTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AtouchesTcbufferGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AtouchesTcbufferGeoLogicalFunction.hpp new file mode 100644 index 0000000000..6e543f8eb5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AtouchesTcbufferGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer always touches the static geometry, 0.0 otherwise. + * + * Args: (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class AtouchesTcbufferGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AtouchesTcbufferGeo"; + + AtouchesTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EcontainsTcbufferGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EcontainsTcbufferGeoLogicalFunction.hpp new file mode 100644 index 0000000000..638f59e1e7 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EcontainsTcbufferGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer ever contains the static geometry, 0.0 otherwise. + * + * Args: (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class EcontainsTcbufferGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EcontainsTcbufferGeo"; + + EcontainsTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EcoversTcbufferGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EcoversTcbufferGeoLogicalFunction.hpp new file mode 100644 index 0000000000..d13d5b4607 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EcoversTcbufferGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer ever covers the static geometry, 0.0 otherwise. + * + * Args: (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class EcoversTcbufferGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EcoversTcbufferGeo"; + + EcoversTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EdisjointTcbufferGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EdisjointTcbufferGeoLogicalFunction.hpp new file mode 100644 index 0000000000..682f6bfaf5 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EdisjointTcbufferGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer is ever disjoint from the static geometry, 0.0 otherwise. + * + * Args: (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class EdisjointTcbufferGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EdisjointTcbufferGeo"; + + EdisjointTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EintersectsTcbufferGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EintersectsTcbufferGeoLogicalFunction.hpp new file mode 100644 index 0000000000..7375b0d981 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EintersectsTcbufferGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer ever intersects the static geometry, 0.0 otherwise. + * + * Args: (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class EintersectsTcbufferGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EintersectsTcbufferGeo"; + + EintersectsTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EtouchesTcbufferGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EtouchesTcbufferGeoLogicalFunction.hpp new file mode 100644 index 0000000000..01e22b284b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EtouchesTcbufferGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer ever touches the static geometry, 0.0 otherwise. + * + * Args: (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class EtouchesTcbufferGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EtouchesTcbufferGeo"; + + EtouchesTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/NadTcbufferGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/NadTcbufferGeoLogicalFunction.hpp new file mode 100644 index 0000000000..8d5967deec --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/NadTcbufferGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nearest approach distance between the tcbuffer and a static geometry. + * + * Args: (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR) -> FLOAT64. + */ +class NadTcbufferGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "NadTcbufferGeo"; + + NadTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AcontainsTcbufferGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AcontainsTcbufferGeoLogicalFunction.cpp new file mode 100644 index 0000000000..9dac9b65de --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AcontainsTcbufferGeoLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AcontainsTcbufferGeoLogicalFunction::AcontainsTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType AcontainsTcbufferGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AcontainsTcbufferGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AcontainsTcbufferGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AcontainsTcbufferGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "AcontainsTcbufferGeoLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AcontainsTcbufferGeoLogicalFunction::getType() const { return NAME; } + +bool AcontainsTcbufferGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AcontainsTcbufferGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AcontainsTcbufferGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "radius must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARCHAR"); + return withChildren(c); +} + +SerializableFunction AcontainsTcbufferGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAcontainsTcbufferGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "AcontainsTcbufferGeoLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return AcontainsTcbufferGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AcoversTcbufferGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AcoversTcbufferGeoLogicalFunction.cpp new file mode 100644 index 0000000000..1d26b552ca --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AcoversTcbufferGeoLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AcoversTcbufferGeoLogicalFunction::AcoversTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType AcoversTcbufferGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AcoversTcbufferGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AcoversTcbufferGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AcoversTcbufferGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "AcoversTcbufferGeoLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AcoversTcbufferGeoLogicalFunction::getType() const { return NAME; } + +bool AcoversTcbufferGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AcoversTcbufferGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AcoversTcbufferGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "radius must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARCHAR"); + return withChildren(c); +} + +SerializableFunction AcoversTcbufferGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAcoversTcbufferGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "AcoversTcbufferGeoLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return AcoversTcbufferGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AdisjointTcbufferGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AdisjointTcbufferGeoLogicalFunction.cpp new file mode 100644 index 0000000000..713a493a0c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AdisjointTcbufferGeoLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AdisjointTcbufferGeoLogicalFunction::AdisjointTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType AdisjointTcbufferGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AdisjointTcbufferGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AdisjointTcbufferGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AdisjointTcbufferGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "AdisjointTcbufferGeoLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AdisjointTcbufferGeoLogicalFunction::getType() const { return NAME; } + +bool AdisjointTcbufferGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AdisjointTcbufferGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AdisjointTcbufferGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "radius must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARCHAR"); + return withChildren(c); +} + +SerializableFunction AdisjointTcbufferGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAdisjointTcbufferGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "AdisjointTcbufferGeoLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return AdisjointTcbufferGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AintersectsTcbufferGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AintersectsTcbufferGeoLogicalFunction.cpp new file mode 100644 index 0000000000..1b400ef7f9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AintersectsTcbufferGeoLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AintersectsTcbufferGeoLogicalFunction::AintersectsTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType AintersectsTcbufferGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AintersectsTcbufferGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AintersectsTcbufferGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AintersectsTcbufferGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "AintersectsTcbufferGeoLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AintersectsTcbufferGeoLogicalFunction::getType() const { return NAME; } + +bool AintersectsTcbufferGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AintersectsTcbufferGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AintersectsTcbufferGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "radius must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARCHAR"); + return withChildren(c); +} + +SerializableFunction AintersectsTcbufferGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAintersectsTcbufferGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "AintersectsTcbufferGeoLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return AintersectsTcbufferGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AtouchesTcbufferGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AtouchesTcbufferGeoLogicalFunction.cpp new file mode 100644 index 0000000000..c1560798e5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AtouchesTcbufferGeoLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AtouchesTcbufferGeoLogicalFunction::AtouchesTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType AtouchesTcbufferGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AtouchesTcbufferGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AtouchesTcbufferGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AtouchesTcbufferGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "AtouchesTcbufferGeoLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AtouchesTcbufferGeoLogicalFunction::getType() const { return NAME; } + +bool AtouchesTcbufferGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AtouchesTcbufferGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AtouchesTcbufferGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "radius must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARCHAR"); + return withChildren(c); +} + +SerializableFunction AtouchesTcbufferGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAtouchesTcbufferGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "AtouchesTcbufferGeoLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return AtouchesTcbufferGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 567fdce526..ea572c1fcd 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -337,6 +337,17 @@ add_plugin(Th3indexCellToCenterChild LogicalFunction nes-logical-operators Th3in add_plugin(Th3indexCellToChildPos LogicalFunction nes-logical-operators Th3indexCellToChildPosLogicalFunction.cpp) add_plugin(Th3indexAreNeighborCells LogicalFunction nes-logical-operators Th3indexAreNeighborCellsLogicalFunction.cpp) add_plugin(Th3indexGridDistance LogicalFunction nes-logical-operators Th3indexGridDistanceLogicalFunction.cpp) +add_plugin(EintersectsTcbufferGeo LogicalFunction nes-logical-operators EintersectsTcbufferGeoLogicalFunction.cpp) +add_plugin(AintersectsTcbufferGeo LogicalFunction nes-logical-operators AintersectsTcbufferGeoLogicalFunction.cpp) +add_plugin(EcoversTcbufferGeo LogicalFunction nes-logical-operators EcoversTcbufferGeoLogicalFunction.cpp) +add_plugin(AcoversTcbufferGeo LogicalFunction nes-logical-operators AcoversTcbufferGeoLogicalFunction.cpp) +add_plugin(EdisjointTcbufferGeo LogicalFunction nes-logical-operators EdisjointTcbufferGeoLogicalFunction.cpp) +add_plugin(AdisjointTcbufferGeo LogicalFunction nes-logical-operators AdisjointTcbufferGeoLogicalFunction.cpp) +add_plugin(EtouchesTcbufferGeo LogicalFunction nes-logical-operators EtouchesTcbufferGeoLogicalFunction.cpp) +add_plugin(AtouchesTcbufferGeo LogicalFunction nes-logical-operators AtouchesTcbufferGeoLogicalFunction.cpp) +add_plugin(EcontainsTcbufferGeo LogicalFunction nes-logical-operators EcontainsTcbufferGeoLogicalFunction.cpp) +add_plugin(AcontainsTcbufferGeo LogicalFunction nes-logical-operators AcontainsTcbufferGeoLogicalFunction.cpp) +add_plugin(NadTcbufferGeo LogicalFunction nes-logical-operators NadTcbufferGeoLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EcontainsTcbufferGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EcontainsTcbufferGeoLogicalFunction.cpp new file mode 100644 index 0000000000..a983252b2d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EcontainsTcbufferGeoLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EcontainsTcbufferGeoLogicalFunction::EcontainsTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType EcontainsTcbufferGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EcontainsTcbufferGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EcontainsTcbufferGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EcontainsTcbufferGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "EcontainsTcbufferGeoLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EcontainsTcbufferGeoLogicalFunction::getType() const { return NAME; } + +bool EcontainsTcbufferGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EcontainsTcbufferGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EcontainsTcbufferGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "radius must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARCHAR"); + return withChildren(c); +} + +SerializableFunction EcontainsTcbufferGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEcontainsTcbufferGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "EcontainsTcbufferGeoLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return EcontainsTcbufferGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EcoversTcbufferGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EcoversTcbufferGeoLogicalFunction.cpp new file mode 100644 index 0000000000..cb46626800 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EcoversTcbufferGeoLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EcoversTcbufferGeoLogicalFunction::EcoversTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType EcoversTcbufferGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EcoversTcbufferGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EcoversTcbufferGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EcoversTcbufferGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "EcoversTcbufferGeoLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EcoversTcbufferGeoLogicalFunction::getType() const { return NAME; } + +bool EcoversTcbufferGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EcoversTcbufferGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EcoversTcbufferGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "radius must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARCHAR"); + return withChildren(c); +} + +SerializableFunction EcoversTcbufferGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEcoversTcbufferGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "EcoversTcbufferGeoLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return EcoversTcbufferGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EdisjointTcbufferGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EdisjointTcbufferGeoLogicalFunction.cpp new file mode 100644 index 0000000000..ea79c9acda --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EdisjointTcbufferGeoLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EdisjointTcbufferGeoLogicalFunction::EdisjointTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType EdisjointTcbufferGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EdisjointTcbufferGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EdisjointTcbufferGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EdisjointTcbufferGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "EdisjointTcbufferGeoLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EdisjointTcbufferGeoLogicalFunction::getType() const { return NAME; } + +bool EdisjointTcbufferGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EdisjointTcbufferGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EdisjointTcbufferGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "radius must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARCHAR"); + return withChildren(c); +} + +SerializableFunction EdisjointTcbufferGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEdisjointTcbufferGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "EdisjointTcbufferGeoLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return EdisjointTcbufferGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EintersectsTcbufferGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EintersectsTcbufferGeoLogicalFunction.cpp new file mode 100644 index 0000000000..acb21c03d5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EintersectsTcbufferGeoLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EintersectsTcbufferGeoLogicalFunction::EintersectsTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType EintersectsTcbufferGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EintersectsTcbufferGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EintersectsTcbufferGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EintersectsTcbufferGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "EintersectsTcbufferGeoLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EintersectsTcbufferGeoLogicalFunction::getType() const { return NAME; } + +bool EintersectsTcbufferGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EintersectsTcbufferGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EintersectsTcbufferGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "radius must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARCHAR"); + return withChildren(c); +} + +SerializableFunction EintersectsTcbufferGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEintersectsTcbufferGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "EintersectsTcbufferGeoLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return EintersectsTcbufferGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EtouchesTcbufferGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EtouchesTcbufferGeoLogicalFunction.cpp new file mode 100644 index 0000000000..9342dd741c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EtouchesTcbufferGeoLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EtouchesTcbufferGeoLogicalFunction::EtouchesTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType EtouchesTcbufferGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EtouchesTcbufferGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EtouchesTcbufferGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EtouchesTcbufferGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "EtouchesTcbufferGeoLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EtouchesTcbufferGeoLogicalFunction::getType() const { return NAME; } + +bool EtouchesTcbufferGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EtouchesTcbufferGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EtouchesTcbufferGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "radius must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARCHAR"); + return withChildren(c); +} + +SerializableFunction EtouchesTcbufferGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEtouchesTcbufferGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "EtouchesTcbufferGeoLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return EtouchesTcbufferGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/NadTcbufferGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/NadTcbufferGeoLogicalFunction.cpp new file mode 100644 index 0000000000..678ff7cebb --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/NadTcbufferGeoLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +NadTcbufferGeoLogicalFunction::NadTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType NadTcbufferGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction NadTcbufferGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector NadTcbufferGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction NadTcbufferGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "NadTcbufferGeoLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view NadTcbufferGeoLogicalFunction::getType() const { return NAME; } + +bool NadTcbufferGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string NadTcbufferGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction NadTcbufferGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "radius must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARCHAR"); + return withChildren(c); +} + +SerializableFunction NadTcbufferGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterNadTcbufferGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "NadTcbufferGeoLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return NadTcbufferGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AcontainsTcbufferGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AcontainsTcbufferGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..5f13a86276 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AcontainsTcbufferGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AcontainsTcbufferGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AcontainsTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AcoversTcbufferGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AcoversTcbufferGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..e4d4381bbe --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AcoversTcbufferGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AcoversTcbufferGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AcoversTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AdisjointTcbufferGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AdisjointTcbufferGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..dd573a50a1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AdisjointTcbufferGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AdisjointTcbufferGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AdisjointTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AintersectsTcbufferGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AintersectsTcbufferGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..d6114f4a3c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AintersectsTcbufferGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AintersectsTcbufferGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AintersectsTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AtouchesTcbufferGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AtouchesTcbufferGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..174402845a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AtouchesTcbufferGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AtouchesTcbufferGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AtouchesTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EcontainsTcbufferGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EcontainsTcbufferGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..8eaa930500 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EcontainsTcbufferGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EcontainsTcbufferGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EcontainsTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EcoversTcbufferGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EcoversTcbufferGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..2c5c6953a3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EcoversTcbufferGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EcoversTcbufferGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EcoversTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EdisjointTcbufferGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EdisjointTcbufferGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..140e6a0e98 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EdisjointTcbufferGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EdisjointTcbufferGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EdisjointTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EintersectsTcbufferGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EintersectsTcbufferGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..47bdf4ea97 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EintersectsTcbufferGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EintersectsTcbufferGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EintersectsTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EtouchesTcbufferGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EtouchesTcbufferGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..a3dede45c9 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EtouchesTcbufferGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EtouchesTcbufferGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EtouchesTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/NadTcbufferGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/NadTcbufferGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..acb4d8ab50 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/NadTcbufferGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class NadTcbufferGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + NadTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AcontainsTcbufferGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AcontainsTcbufferGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..1df12b657a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AcontainsTcbufferGeoPhysicalFunction.cpp @@ -0,0 +1,104 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AcontainsTcbufferGeoPhysicalFunction::AcontainsTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(radius)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal AcontainsTcbufferGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto radius = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + + const auto result = nautilus::invoke( + +[](double lon, double lat, double radius, uint64_t ts, + const char* wkt, uint32_t wkt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant: point + radius → cbuffer → instant + std::string pt_str = fmt::format("POINT({} {})", lon, lat); + GSERIALIZED* pt_gs = geom_in(pt_str.c_str(), -1); + if (!pt_gs) return 0.0; + Cbuffer* cb = cbuffer_make(pt_gs, radius); + free(pt_gs); + if (!cb) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb, (TimestampTz)ts); + free(cb); + if (!tcb_inst) return 0.0; + // Build target geometry from null-terminated WKT copy + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* target_gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!target_gs) { free(tcb_inst); return 0.0; } + int r = acontains_tcbuffer_geo(tcb_inst, target_gs); + free(tcb_inst); + free(target_gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, radius, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAcontainsTcbufferGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "AcontainsTcbufferGeoPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return AcontainsTcbufferGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AcoversTcbufferGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AcoversTcbufferGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..5296b89f95 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AcoversTcbufferGeoPhysicalFunction.cpp @@ -0,0 +1,104 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AcoversTcbufferGeoPhysicalFunction::AcoversTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(radius)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal AcoversTcbufferGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto radius = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + + const auto result = nautilus::invoke( + +[](double lon, double lat, double radius, uint64_t ts, + const char* wkt, uint32_t wkt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant: point + radius → cbuffer → instant + std::string pt_str = fmt::format("POINT({} {})", lon, lat); + GSERIALIZED* pt_gs = geom_in(pt_str.c_str(), -1); + if (!pt_gs) return 0.0; + Cbuffer* cb = cbuffer_make(pt_gs, radius); + free(pt_gs); + if (!cb) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb, (TimestampTz)ts); + free(cb); + if (!tcb_inst) return 0.0; + // Build target geometry from null-terminated WKT copy + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* target_gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!target_gs) { free(tcb_inst); return 0.0; } + int r = acovers_tcbuffer_geo(tcb_inst, target_gs); + free(tcb_inst); + free(target_gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, radius, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAcoversTcbufferGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "AcoversTcbufferGeoPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return AcoversTcbufferGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AdisjointTcbufferGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AdisjointTcbufferGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..4657c698eb --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AdisjointTcbufferGeoPhysicalFunction.cpp @@ -0,0 +1,104 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AdisjointTcbufferGeoPhysicalFunction::AdisjointTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(radius)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal AdisjointTcbufferGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto radius = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + + const auto result = nautilus::invoke( + +[](double lon, double lat, double radius, uint64_t ts, + const char* wkt, uint32_t wkt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant: point + radius → cbuffer → instant + std::string pt_str = fmt::format("POINT({} {})", lon, lat); + GSERIALIZED* pt_gs = geom_in(pt_str.c_str(), -1); + if (!pt_gs) return 0.0; + Cbuffer* cb = cbuffer_make(pt_gs, radius); + free(pt_gs); + if (!cb) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb, (TimestampTz)ts); + free(cb); + if (!tcb_inst) return 0.0; + // Build target geometry from null-terminated WKT copy + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* target_gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!target_gs) { free(tcb_inst); return 0.0; } + int r = adisjoint_tcbuffer_geo(tcb_inst, target_gs); + free(tcb_inst); + free(target_gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, radius, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAdisjointTcbufferGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "AdisjointTcbufferGeoPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return AdisjointTcbufferGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AintersectsTcbufferGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AintersectsTcbufferGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..29ddcc1a02 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AintersectsTcbufferGeoPhysicalFunction.cpp @@ -0,0 +1,104 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AintersectsTcbufferGeoPhysicalFunction::AintersectsTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(radius)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal AintersectsTcbufferGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto radius = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + + const auto result = nautilus::invoke( + +[](double lon, double lat, double radius, uint64_t ts, + const char* wkt, uint32_t wkt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant: point + radius → cbuffer → instant + std::string pt_str = fmt::format("POINT({} {})", lon, lat); + GSERIALIZED* pt_gs = geom_in(pt_str.c_str(), -1); + if (!pt_gs) return 0.0; + Cbuffer* cb = cbuffer_make(pt_gs, radius); + free(pt_gs); + if (!cb) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb, (TimestampTz)ts); + free(cb); + if (!tcb_inst) return 0.0; + // Build target geometry from null-terminated WKT copy + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* target_gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!target_gs) { free(tcb_inst); return 0.0; } + int r = aintersects_tcbuffer_geo(tcb_inst, target_gs); + free(tcb_inst); + free(target_gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, radius, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAintersectsTcbufferGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "AintersectsTcbufferGeoPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return AintersectsTcbufferGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AtouchesTcbufferGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AtouchesTcbufferGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..cc651d7b83 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AtouchesTcbufferGeoPhysicalFunction.cpp @@ -0,0 +1,104 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AtouchesTcbufferGeoPhysicalFunction::AtouchesTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(radius)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal AtouchesTcbufferGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto radius = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + + const auto result = nautilus::invoke( + +[](double lon, double lat, double radius, uint64_t ts, + const char* wkt, uint32_t wkt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant: point + radius → cbuffer → instant + std::string pt_str = fmt::format("POINT({} {})", lon, lat); + GSERIALIZED* pt_gs = geom_in(pt_str.c_str(), -1); + if (!pt_gs) return 0.0; + Cbuffer* cb = cbuffer_make(pt_gs, radius); + free(pt_gs); + if (!cb) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb, (TimestampTz)ts); + free(cb); + if (!tcb_inst) return 0.0; + // Build target geometry from null-terminated WKT copy + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* target_gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!target_gs) { free(tcb_inst); return 0.0; } + int r = atouches_tcbuffer_geo(tcb_inst, target_gs); + free(tcb_inst); + free(target_gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, radius, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAtouchesTcbufferGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "AtouchesTcbufferGeoPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return AtouchesTcbufferGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 1b3ab90e67..c5292978c0 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -336,6 +336,17 @@ add_plugin(Th3indexCellToCenterChild PhysicalFunction nes-physical-operators Th3 add_plugin(Th3indexCellToChildPos PhysicalFunction nes-physical-operators Th3indexCellToChildPosPhysicalFunction.cpp) add_plugin(Th3indexAreNeighborCells PhysicalFunction nes-physical-operators Th3indexAreNeighborCellsPhysicalFunction.cpp) add_plugin(Th3indexGridDistance PhysicalFunction nes-physical-operators Th3indexGridDistancePhysicalFunction.cpp) +add_plugin(EintersectsTcbufferGeo PhysicalFunction nes-physical-operators EintersectsTcbufferGeoPhysicalFunction.cpp) +add_plugin(AintersectsTcbufferGeo PhysicalFunction nes-physical-operators AintersectsTcbufferGeoPhysicalFunction.cpp) +add_plugin(EcoversTcbufferGeo PhysicalFunction nes-physical-operators EcoversTcbufferGeoPhysicalFunction.cpp) +add_plugin(AcoversTcbufferGeo PhysicalFunction nes-physical-operators AcoversTcbufferGeoPhysicalFunction.cpp) +add_plugin(EdisjointTcbufferGeo PhysicalFunction nes-physical-operators EdisjointTcbufferGeoPhysicalFunction.cpp) +add_plugin(AdisjointTcbufferGeo PhysicalFunction nes-physical-operators AdisjointTcbufferGeoPhysicalFunction.cpp) +add_plugin(EtouchesTcbufferGeo PhysicalFunction nes-physical-operators EtouchesTcbufferGeoPhysicalFunction.cpp) +add_plugin(AtouchesTcbufferGeo PhysicalFunction nes-physical-operators AtouchesTcbufferGeoPhysicalFunction.cpp) +add_plugin(EcontainsTcbufferGeo PhysicalFunction nes-physical-operators EcontainsTcbufferGeoPhysicalFunction.cpp) +add_plugin(AcontainsTcbufferGeo PhysicalFunction nes-physical-operators AcontainsTcbufferGeoPhysicalFunction.cpp) +add_plugin(NadTcbufferGeo PhysicalFunction nes-physical-operators NadTcbufferGeoPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EcontainsTcbufferGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EcontainsTcbufferGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..18addc2839 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EcontainsTcbufferGeoPhysicalFunction.cpp @@ -0,0 +1,104 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EcontainsTcbufferGeoPhysicalFunction::EcontainsTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(radius)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal EcontainsTcbufferGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto radius = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + + const auto result = nautilus::invoke( + +[](double lon, double lat, double radius, uint64_t ts, + const char* wkt, uint32_t wkt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant: point + radius → cbuffer → instant + std::string pt_str = fmt::format("POINT({} {})", lon, lat); + GSERIALIZED* pt_gs = geom_in(pt_str.c_str(), -1); + if (!pt_gs) return 0.0; + Cbuffer* cb = cbuffer_make(pt_gs, radius); + free(pt_gs); + if (!cb) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb, (TimestampTz)ts); + free(cb); + if (!tcb_inst) return 0.0; + // Build target geometry from null-terminated WKT copy + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* target_gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!target_gs) { free(tcb_inst); return 0.0; } + int r = econtains_tcbuffer_geo(tcb_inst, target_gs); + free(tcb_inst); + free(target_gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, radius, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEcontainsTcbufferGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "EcontainsTcbufferGeoPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return EcontainsTcbufferGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EcoversTcbufferGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EcoversTcbufferGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..ddea00a297 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EcoversTcbufferGeoPhysicalFunction.cpp @@ -0,0 +1,104 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EcoversTcbufferGeoPhysicalFunction::EcoversTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(radius)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal EcoversTcbufferGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto radius = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + + const auto result = nautilus::invoke( + +[](double lon, double lat, double radius, uint64_t ts, + const char* wkt, uint32_t wkt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant: point + radius → cbuffer → instant + std::string pt_str = fmt::format("POINT({} {})", lon, lat); + GSERIALIZED* pt_gs = geom_in(pt_str.c_str(), -1); + if (!pt_gs) return 0.0; + Cbuffer* cb = cbuffer_make(pt_gs, radius); + free(pt_gs); + if (!cb) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb, (TimestampTz)ts); + free(cb); + if (!tcb_inst) return 0.0; + // Build target geometry from null-terminated WKT copy + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* target_gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!target_gs) { free(tcb_inst); return 0.0; } + int r = ecovers_tcbuffer_geo(tcb_inst, target_gs); + free(tcb_inst); + free(target_gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, radius, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEcoversTcbufferGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "EcoversTcbufferGeoPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return EcoversTcbufferGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EdisjointTcbufferGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EdisjointTcbufferGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..ef4bf0993c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EdisjointTcbufferGeoPhysicalFunction.cpp @@ -0,0 +1,104 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EdisjointTcbufferGeoPhysicalFunction::EdisjointTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(radius)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal EdisjointTcbufferGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto radius = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + + const auto result = nautilus::invoke( + +[](double lon, double lat, double radius, uint64_t ts, + const char* wkt, uint32_t wkt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant: point + radius → cbuffer → instant + std::string pt_str = fmt::format("POINT({} {})", lon, lat); + GSERIALIZED* pt_gs = geom_in(pt_str.c_str(), -1); + if (!pt_gs) return 0.0; + Cbuffer* cb = cbuffer_make(pt_gs, radius); + free(pt_gs); + if (!cb) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb, (TimestampTz)ts); + free(cb); + if (!tcb_inst) return 0.0; + // Build target geometry from null-terminated WKT copy + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* target_gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!target_gs) { free(tcb_inst); return 0.0; } + int r = edisjoint_tcbuffer_geo(tcb_inst, target_gs); + free(tcb_inst); + free(target_gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, radius, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEdisjointTcbufferGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "EdisjointTcbufferGeoPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return EdisjointTcbufferGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EintersectsTcbufferGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EintersectsTcbufferGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..b2ffefe945 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EintersectsTcbufferGeoPhysicalFunction.cpp @@ -0,0 +1,104 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EintersectsTcbufferGeoPhysicalFunction::EintersectsTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(radius)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal EintersectsTcbufferGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto radius = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + + const auto result = nautilus::invoke( + +[](double lon, double lat, double radius, uint64_t ts, + const char* wkt, uint32_t wkt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant: point + radius → cbuffer → instant + std::string pt_str = fmt::format("POINT({} {})", lon, lat); + GSERIALIZED* pt_gs = geom_in(pt_str.c_str(), -1); + if (!pt_gs) return 0.0; + Cbuffer* cb = cbuffer_make(pt_gs, radius); + free(pt_gs); + if (!cb) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb, (TimestampTz)ts); + free(cb); + if (!tcb_inst) return 0.0; + // Build target geometry from null-terminated WKT copy + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* target_gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!target_gs) { free(tcb_inst); return 0.0; } + int r = eintersects_tcbuffer_geo(tcb_inst, target_gs); + free(tcb_inst); + free(target_gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, radius, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEintersectsTcbufferGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "EintersectsTcbufferGeoPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return EintersectsTcbufferGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EtouchesTcbufferGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EtouchesTcbufferGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..cb9ab44e8e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EtouchesTcbufferGeoPhysicalFunction.cpp @@ -0,0 +1,104 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EtouchesTcbufferGeoPhysicalFunction::EtouchesTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(radius)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal EtouchesTcbufferGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto radius = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + + const auto result = nautilus::invoke( + +[](double lon, double lat, double radius, uint64_t ts, + const char* wkt, uint32_t wkt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant: point + radius → cbuffer → instant + std::string pt_str = fmt::format("POINT({} {})", lon, lat); + GSERIALIZED* pt_gs = geom_in(pt_str.c_str(), -1); + if (!pt_gs) return 0.0; + Cbuffer* cb = cbuffer_make(pt_gs, radius); + free(pt_gs); + if (!cb) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb, (TimestampTz)ts); + free(cb); + if (!tcb_inst) return 0.0; + // Build target geometry from null-terminated WKT copy + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* target_gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!target_gs) { free(tcb_inst); return 0.0; } + int r = etouches_tcbuffer_geo(tcb_inst, target_gs); + free(tcb_inst); + free(target_gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, radius, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEtouchesTcbufferGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "EtouchesTcbufferGeoPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return EtouchesTcbufferGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/NadTcbufferGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/NadTcbufferGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..9c53b9dd6e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/NadTcbufferGeoPhysicalFunction.cpp @@ -0,0 +1,104 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +NadTcbufferGeoPhysicalFunction::NadTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(radius)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal NadTcbufferGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto radius = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + + const auto result = nautilus::invoke( + +[](double lon, double lat, double radius, uint64_t ts, + const char* wkt, uint32_t wkt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant: point + radius → cbuffer → instant + std::string pt_str = fmt::format("POINT({} {})", lon, lat); + GSERIALIZED* pt_gs = geom_in(pt_str.c_str(), -1); + if (!pt_gs) return 0.0; + Cbuffer* cb = cbuffer_make(pt_gs, radius); + free(pt_gs); + if (!cb) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb, (TimestampTz)ts); + free(cb); + if (!tcb_inst) return 0.0; + // Build target geometry from null-terminated WKT copy + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* target_gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!target_gs) { free(tcb_inst); return 0.0; } + double r = nad_tcbuffer_geo(tcb_inst, target_gs); + free(tcb_inst); + free(target_gs); + return r; + } catch (const std::exception&) { return -1.0; } + }, + lon, lat, radius, ts, wkt); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterNadTcbufferGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "NadTcbufferGeoPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return NadTcbufferGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 5a6e7111ec..d7c1b2c2c8 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -807,6 +807,17 @@ TH3INDEX_CELL_TO_CENTER_CHILD: 'TH3INDEX_CELL_TO_CENTER_CHILD' | 'th3index_cell_ TH3INDEX_CELL_TO_CHILD_POS: 'TH3INDEX_CELL_TO_CHILD_POS' | 'th3index_cell_to_child_pos'; TH3INDEX_ARE_NEIGHBOR_CELLS: 'TH3INDEX_ARE_NEIGHBOR_CELLS' | 'th3index_are_neighbor_cells'; TH3INDEX_GRID_DISTANCE: 'TH3INDEX_GRID_DISTANCE' | 'th3index_grid_distance'; +EINTERSECTS_TCBUFFER_GEO: 'EINTERSECTS_TCBUFFER_GEO' | 'eintersects_tcbuffer_geo'; +AINTERSECTS_TCBUFFER_GEO: 'AINTERSECTS_TCBUFFER_GEO' | 'aintersects_tcbuffer_geo'; +ECOVERS_TCBUFFER_GEO: 'ECOVERS_TCBUFFER_GEO' | 'ecovers_tcbuffer_geo'; +ACOVERS_TCBUFFER_GEO: 'ACOVERS_TCBUFFER_GEO' | 'acovers_tcbuffer_geo'; +EDISJOINT_TCBUFFER_GEO: 'EDISJOINT_TCBUFFER_GEO' | 'edisjoint_tcbuffer_geo'; +ADISJOINT_TCBUFFER_GEO: 'ADISJOINT_TCBUFFER_GEO' | 'adisjoint_tcbuffer_geo'; +ETOUCHES_TCBUFFER_GEO: 'ETOUCHES_TCBUFFER_GEO' | 'etouches_tcbuffer_geo'; +ATOUCHES_TCBUFFER_GEO: 'ATOUCHES_TCBUFFER_GEO' | 'atouches_tcbuffer_geo'; +ECONTAINS_TCBUFFER_GEO: 'ECONTAINS_TCBUFFER_GEO' | 'econtains_tcbuffer_geo'; +ACONTAINS_TCBUFFER_GEO: 'ACONTAINS_TCBUFFER_GEO' | 'acontains_tcbuffer_geo'; +NAD_TCBUFFER_GEO: 'NAD_TCBUFFER_GEO' | 'nad_tcbuffer_geo'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 364ad25082..806bee662d 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -388,6 +388,17 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -9294,6 +9305,138 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(Th3indexGridDistanceLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); } /* END CODEGEN PARSER GLUE: TH3INDEX_GRID_DISTANCE */ + case AntlrSQLParser::EINTERSECTS_TCBUFFER_GEO: { + PRECONDITION(ctx->functionParam().size() == 5, + "EintersectsTcbufferGeo requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(EintersectsTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: EINTERSECTS_TCBUFFER_GEO */ + case AntlrSQLParser::AINTERSECTS_TCBUFFER_GEO: { + PRECONDITION(ctx->functionParam().size() == 5, + "AintersectsTcbufferGeo requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(AintersectsTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: AINTERSECTS_TCBUFFER_GEO */ + case AntlrSQLParser::ECOVERS_TCBUFFER_GEO: { + PRECONDITION(ctx->functionParam().size() == 5, + "EcoversTcbufferGeo requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(EcoversTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: ECOVERS_TCBUFFER_GEO */ + case AntlrSQLParser::ACOVERS_TCBUFFER_GEO: { + PRECONDITION(ctx->functionParam().size() == 5, + "AcoversTcbufferGeo requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(AcoversTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: ACOVERS_TCBUFFER_GEO */ + case AntlrSQLParser::EDISJOINT_TCBUFFER_GEO: { + PRECONDITION(ctx->functionParam().size() == 5, + "EdisjointTcbufferGeo requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(EdisjointTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: EDISJOINT_TCBUFFER_GEO */ + case AntlrSQLParser::ADISJOINT_TCBUFFER_GEO: { + PRECONDITION(ctx->functionParam().size() == 5, + "AdisjointTcbufferGeo requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(AdisjointTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: ADISJOINT_TCBUFFER_GEO */ + case AntlrSQLParser::ETOUCHES_TCBUFFER_GEO: { + PRECONDITION(ctx->functionParam().size() == 5, + "EtouchesTcbufferGeo requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(EtouchesTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: ETOUCHES_TCBUFFER_GEO */ + case AntlrSQLParser::ATOUCHES_TCBUFFER_GEO: { + PRECONDITION(ctx->functionParam().size() == 5, + "AtouchesTcbufferGeo requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(AtouchesTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: ATOUCHES_TCBUFFER_GEO */ + case AntlrSQLParser::ECONTAINS_TCBUFFER_GEO: { + PRECONDITION(ctx->functionParam().size() == 5, + "EcontainsTcbufferGeo requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(EcontainsTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: ECONTAINS_TCBUFFER_GEO */ + case AntlrSQLParser::ACONTAINS_TCBUFFER_GEO: { + PRECONDITION(ctx->functionParam().size() == 5, + "AcontainsTcbufferGeo requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(AcontainsTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: ACONTAINS_TCBUFFER_GEO */ + case AntlrSQLParser::NAD_TCBUFFER_GEO: { + PRECONDITION(ctx->functionParam().size() == 5, + "NadTcbufferGeo requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(NadTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: NAD_TCBUFFER_GEO */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 9c6c5c0cdf2c967b1733cef506efb39ef879e98a Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 04:48:15 +0200 Subject: [PATCH 62/86] feat(meos): add EDWITHIN_TCBUFFER_GEO and ADWITHIN_TCBUFFER_GEO NES operators (W114) Wires two tcbuffer within-distance per-event operators using a new 6-arg pattern (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR, dist:FLOAT64) -> FLOAT64. EDWITHIN_TCBUFFER_GEO returns 1.0 if the tcbuffer instant ever comes within dist of the static geometry; ADWITHIN_TCBUFFER_GEO returns 1.0 if it is always within dist. --- .../AdwithinTcbufferGeoLogicalFunction.hpp | 52 ++++++++ .../EdwithinTcbufferGeoLogicalFunction.hpp | 52 ++++++++ .../AdwithinTcbufferGeoLogicalFunction.cpp | 116 ++++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../EdwithinTcbufferGeoLogicalFunction.cpp | 116 ++++++++++++++++++ .../AdwithinTcbufferGeoPhysicalFunction.hpp | 36 ++++++ .../EdwithinTcbufferGeoPhysicalFunction.hpp | 36 ++++++ .../AdwithinTcbufferGeoPhysicalFunction.cpp | 107 ++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../EdwithinTcbufferGeoPhysicalFunction.cpp | 107 ++++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 4 +- .../src/AntlrSQLQueryPlanCreator.cpp | 28 +++++ 12 files changed, 657 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AdwithinTcbufferGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EdwithinTcbufferGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AdwithinTcbufferGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EdwithinTcbufferGeoLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AdwithinTcbufferGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EdwithinTcbufferGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AdwithinTcbufferGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EdwithinTcbufferGeoPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AdwithinTcbufferGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AdwithinTcbufferGeoLogicalFunction.hpp new file mode 100644 index 0000000000..f67ef27054 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AdwithinTcbufferGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer is always within dist of the static geometry, 0.0 otherwise. + * + * Args: (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR, dist:FLOAT64) -> FLOAT64. + */ +class AdwithinTcbufferGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AdwithinTcbufferGeo"; + + AdwithinTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt, LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EdwithinTcbufferGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EdwithinTcbufferGeoLogicalFunction.hpp new file mode 100644 index 0000000000..d9dcc36c65 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EdwithinTcbufferGeoLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer ever comes within dist of the static geometry, 0.0 otherwise. + * + * Args: (lon:FLOAT64, lat:FLOAT64, radius:FLOAT64, ts:UINT64, wkt:VARCHAR, dist:FLOAT64) -> FLOAT64. + */ +class EdwithinTcbufferGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EdwithinTcbufferGeo"; + + EdwithinTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt, LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AdwithinTcbufferGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AdwithinTcbufferGeoLogicalFunction.cpp new file mode 100644 index 0000000000..66049ca77d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AdwithinTcbufferGeoLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AdwithinTcbufferGeoLogicalFunction::AdwithinTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt, LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(dist)); +} + +DataType AdwithinTcbufferGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AdwithinTcbufferGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AdwithinTcbufferGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AdwithinTcbufferGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AdwithinTcbufferGeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AdwithinTcbufferGeoLogicalFunction::getType() const { return NAME; } + +bool AdwithinTcbufferGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AdwithinTcbufferGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AdwithinTcbufferGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + c.emplace_back(parameters[5].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "radius must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARCHAR"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "dist must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AdwithinTcbufferGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAdwithinTcbufferGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AdwithinTcbufferGeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AdwithinTcbufferGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index ea572c1fcd..1d83d1dc98 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -348,6 +348,8 @@ add_plugin(AtouchesTcbufferGeo LogicalFunction nes-logical-operators AtouchesTcb add_plugin(EcontainsTcbufferGeo LogicalFunction nes-logical-operators EcontainsTcbufferGeoLogicalFunction.cpp) add_plugin(AcontainsTcbufferGeo LogicalFunction nes-logical-operators AcontainsTcbufferGeoLogicalFunction.cpp) add_plugin(NadTcbufferGeo LogicalFunction nes-logical-operators NadTcbufferGeoLogicalFunction.cpp) +add_plugin(EdwithinTcbufferGeo LogicalFunction nes-logical-operators EdwithinTcbufferGeoLogicalFunction.cpp) +add_plugin(AdwithinTcbufferGeo LogicalFunction nes-logical-operators AdwithinTcbufferGeoLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EdwithinTcbufferGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EdwithinTcbufferGeoLogicalFunction.cpp new file mode 100644 index 0000000000..a918723e2f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EdwithinTcbufferGeoLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EdwithinTcbufferGeoLogicalFunction::EdwithinTcbufferGeoLogicalFunction(LogicalFunction lon, LogicalFunction lat, + LogicalFunction radius, LogicalFunction ts, + LogicalFunction wkt, LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(radius)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(dist)); +} + +DataType EdwithinTcbufferGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EdwithinTcbufferGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EdwithinTcbufferGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EdwithinTcbufferGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EdwithinTcbufferGeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EdwithinTcbufferGeoLogicalFunction::getType() const { return NAME; } + +bool EdwithinTcbufferGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EdwithinTcbufferGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EdwithinTcbufferGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + c.emplace_back(parameters[3].withInferredDataType(schema)); + c.emplace_back(parameters[4].withInferredDataType(schema)); + c.emplace_back(parameters[5].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "radius must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARCHAR"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "dist must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EdwithinTcbufferGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEdwithinTcbufferGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EdwithinTcbufferGeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EdwithinTcbufferGeoLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AdwithinTcbufferGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AdwithinTcbufferGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..62bfbd22eb --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AdwithinTcbufferGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AdwithinTcbufferGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AdwithinTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt, PhysicalFunction dist); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EdwithinTcbufferGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EdwithinTcbufferGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..9dbb55e258 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EdwithinTcbufferGeoPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EdwithinTcbufferGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EdwithinTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt, PhysicalFunction dist); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AdwithinTcbufferGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AdwithinTcbufferGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..f49454910a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AdwithinTcbufferGeoPhysicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AdwithinTcbufferGeoPhysicalFunction::AdwithinTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt, PhysicalFunction dist) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(radius)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(dist)); +} + +VarVal AdwithinTcbufferGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto radius = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + auto dist = paramFns[5].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, double radius, uint64_t ts, + const char* wkt, uint32_t wkt_len, double dist) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from lon/lat/radius/ts + std::string pt_str = fmt::format("POINT({} {})", lon, lat); + GSERIALIZED* pt_gs = geom_in(pt_str.c_str(), -1); + if (!pt_gs) return 0.0; + Cbuffer* cb = cbuffer_make(pt_gs, radius); + free(pt_gs); + if (!cb) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb, (TimestampTz)ts); + free(cb); + if (!tcb_inst) return 0.0; + // Build target geometry from null-terminated WKT copy + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* target_gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!target_gs) { free(tcb_inst); return 0.0; } + int r = adwithin_tcbuffer_geo(tcb_inst, target_gs, dist); + free(tcb_inst); + free(target_gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, radius, ts, wkt, dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAdwithinTcbufferGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AdwithinTcbufferGeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AdwithinTcbufferGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index c5292978c0..33e9b9a416 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -347,6 +347,8 @@ add_plugin(AtouchesTcbufferGeo PhysicalFunction nes-physical-operators AtouchesT add_plugin(EcontainsTcbufferGeo PhysicalFunction nes-physical-operators EcontainsTcbufferGeoPhysicalFunction.cpp) add_plugin(AcontainsTcbufferGeo PhysicalFunction nes-physical-operators AcontainsTcbufferGeoPhysicalFunction.cpp) add_plugin(NadTcbufferGeo PhysicalFunction nes-physical-operators NadTcbufferGeoPhysicalFunction.cpp) +add_plugin(EdwithinTcbufferGeo PhysicalFunction nes-physical-operators EdwithinTcbufferGeoPhysicalFunction.cpp) +add_plugin(AdwithinTcbufferGeo PhysicalFunction nes-physical-operators AdwithinTcbufferGeoPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EdwithinTcbufferGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EdwithinTcbufferGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..074a407bb2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EdwithinTcbufferGeoPhysicalFunction.cpp @@ -0,0 +1,107 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EdwithinTcbufferGeoPhysicalFunction::EdwithinTcbufferGeoPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, + PhysicalFunction radius, PhysicalFunction ts, + PhysicalFunction wkt, PhysicalFunction dist) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(radius)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(dist)); +} + +VarVal EdwithinTcbufferGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto radius = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + auto dist = paramFns[5].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon, double lat, double radius, uint64_t ts, + const char* wkt, uint32_t wkt_len, double dist) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from lon/lat/radius/ts + std::string pt_str = fmt::format("POINT({} {})", lon, lat); + GSERIALIZED* pt_gs = geom_in(pt_str.c_str(), -1); + if (!pt_gs) return 0.0; + Cbuffer* cb = cbuffer_make(pt_gs, radius); + free(pt_gs); + if (!cb) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb, (TimestampTz)ts); + free(cb); + if (!tcb_inst) return 0.0; + // Build target geometry from null-terminated WKT copy + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* target_gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!target_gs) { free(tcb_inst); return 0.0; } + int r = edwithin_tcbuffer_geo(tcb_inst, target_gs, dist); + free(tcb_inst); + free(target_gs); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon, lat, radius, ts, wkt, dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEdwithinTcbufferGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EdwithinTcbufferGeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EdwithinTcbufferGeoPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index d7c1b2c2c8..b054846852 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -818,6 +818,8 @@ ATOUCHES_TCBUFFER_GEO: 'ATOUCHES_TCBUFFER_GEO' | 'atouches_tcbuffer_geo'; ECONTAINS_TCBUFFER_GEO: 'ECONTAINS_TCBUFFER_GEO' | 'econtains_tcbuffer_geo'; ACONTAINS_TCBUFFER_GEO: 'ACONTAINS_TCBUFFER_GEO' | 'acontains_tcbuffer_geo'; NAD_TCBUFFER_GEO: 'NAD_TCBUFFER_GEO' | 'nad_tcbuffer_geo'; +EDWITHIN_TCBUFFER_GEO: 'EDWITHIN_TCBUFFER_GEO' | 'edwithin_tcbuffer_geo'; +ADWITHIN_TCBUFFER_GEO: 'ADWITHIN_TCBUFFER_GEO' | 'adwithin_tcbuffer_geo'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 806bee662d..ae848f26ce 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -399,6 +399,8 @@ #include #include #include +#include +#include #include #include #include @@ -9437,6 +9439,32 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(NadTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); } /* END CODEGEN PARSER GLUE: NAD_TCBUFFER_GEO */ + case AntlrSQLParser::EDWITHIN_TCBUFFER_GEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "EdwithinTcbufferGeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EdwithinTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: EDWITHIN_TCBUFFER_GEO */ + case AntlrSQLParser::ADWITHIN_TCBUFFER_GEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "AdwithinTcbufferGeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AdwithinTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ADWITHIN_TCBUFFER_GEO */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 21413f262df82adc767dbc89939f7cc4ec1c58b2 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 05:45:10 +0200 Subject: [PATCH 63/86] feat(meos): add tcbuffer_cbuffer spatial predicate NES operators (W115) Wires fifteen tcbuffer-vs-static-cbuffer per-event operators using a new 7-arg all-numeric pattern (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. The physical functions build a tcbuffer instant from the first lon/lat/radius/ts group and a static Cbuffer from the second lon/lat/radius group. Operators: EINTERSECTS/AINTERSECTS, ECOVERS/ACOVERS, EDISJOINT/ADISJOINT, ETOUCHES/ATOUCHES, ECONTAINS/ACONTAINS, EVER_EQ/ALWAYS_EQ, EVER_NE/ALWAYS_NE _TCBUFFER_CBUFFER, and NAD_TCBUFFER_CBUFFER. --- ...containsTcbufferCbufferLogicalFunction.hpp | 53 +++++ .../AcoversTcbufferCbufferLogicalFunction.hpp | 53 +++++ ...disjointTcbufferCbufferLogicalFunction.hpp | 53 +++++ ...tersectsTcbufferCbufferLogicalFunction.hpp | 53 +++++ ...AlwaysEqTcbufferCbufferLogicalFunction.hpp | 53 +++++ ...AlwaysNeTcbufferCbufferLogicalFunction.hpp | 53 +++++ ...AtouchesTcbufferCbufferLogicalFunction.hpp | 53 +++++ ...containsTcbufferCbufferLogicalFunction.hpp | 53 +++++ .../EcoversTcbufferCbufferLogicalFunction.hpp | 53 +++++ ...disjointTcbufferCbufferLogicalFunction.hpp | 53 +++++ ...tersectsTcbufferCbufferLogicalFunction.hpp | 53 +++++ ...EtouchesTcbufferCbufferLogicalFunction.hpp | 53 +++++ .../EverEqTcbufferCbufferLogicalFunction.hpp | 53 +++++ .../EverNeTcbufferCbufferLogicalFunction.hpp | 53 +++++ .../NadTcbufferCbufferLogicalFunction.hpp | 53 +++++ ...containsTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ .../AcoversTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ ...disjointTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ ...tersectsTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ ...AlwaysEqTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ ...AlwaysNeTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ ...AtouchesTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 15 ++ ...containsTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ .../EcoversTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ ...disjointTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ ...tersectsTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ ...EtouchesTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ .../EverEqTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ .../EverNeTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ .../NadTcbufferCbufferLogicalFunction.cpp | 116 +++++++++ ...ontainsTcbufferCbufferPhysicalFunction.hpp | 36 +++ ...AcoversTcbufferCbufferPhysicalFunction.hpp | 36 +++ ...isjointTcbufferCbufferPhysicalFunction.hpp | 36 +++ ...ersectsTcbufferCbufferPhysicalFunction.hpp | 36 +++ ...lwaysEqTcbufferCbufferPhysicalFunction.hpp | 36 +++ ...lwaysNeTcbufferCbufferPhysicalFunction.hpp | 36 +++ ...touchesTcbufferCbufferPhysicalFunction.hpp | 36 +++ ...ontainsTcbufferCbufferPhysicalFunction.hpp | 36 +++ ...EcoversTcbufferCbufferPhysicalFunction.hpp | 36 +++ ...isjointTcbufferCbufferPhysicalFunction.hpp | 36 +++ ...ersectsTcbufferCbufferPhysicalFunction.hpp | 36 +++ ...touchesTcbufferCbufferPhysicalFunction.hpp | 36 +++ .../EverEqTcbufferCbufferPhysicalFunction.hpp | 36 +++ .../EverNeTcbufferCbufferPhysicalFunction.hpp | 36 +++ .../NadTcbufferCbufferPhysicalFunction.hpp | 36 +++ ...ontainsTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ ...AcoversTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ ...isjointTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ ...ersectsTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ ...lwaysEqTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ ...lwaysNeTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ ...touchesTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 15 ++ ...ontainsTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ ...EcoversTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ ...isjointTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ ...ersectsTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ ...touchesTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ .../EverEqTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ .../EverNeTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ .../NadTcbufferCbufferPhysicalFunction.cpp | 110 +++++++++ nes-sql-parser/AntlrSQL.g4 | 17 +- .../src/AntlrSQLQueryPlanCreator.cpp | 225 ++++++++++++++++++ 64 files changed, 4996 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AcontainsTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AcoversTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AdisjointTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AintersectsTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AtouchesTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EcontainsTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EcoversTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EdisjointTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EintersectsTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EtouchesTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/NadTcbufferCbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AcontainsTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AcoversTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AdisjointTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AintersectsTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AtouchesTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EcontainsTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EcoversTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EdisjointTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EintersectsTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EtouchesTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/NadTcbufferCbufferLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AcontainsTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AcoversTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AdisjointTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AintersectsTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AtouchesTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EcontainsTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EcoversTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EdisjointTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EintersectsTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EtouchesTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/NadTcbufferCbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AcontainsTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AcoversTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AdisjointTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AintersectsTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AtouchesTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EcontainsTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EcoversTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EdisjointTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EintersectsTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EtouchesTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTcbufferCbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/NadTcbufferCbufferPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AcontainsTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AcontainsTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..6d86d5a22c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AcontainsTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer always contains the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class AcontainsTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AcontainsTcbufferCbuffer"; + + AcontainsTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AcoversTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AcoversTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..85b4976e6f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AcoversTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer always covers the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class AcoversTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AcoversTcbufferCbuffer"; + + AcoversTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AdisjointTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AdisjointTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..f5fc8bca58 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AdisjointTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer is always disjoint from the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class AdisjointTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AdisjointTcbufferCbuffer"; + + AdisjointTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AintersectsTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AintersectsTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..21b170cef0 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AintersectsTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer always intersects the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class AintersectsTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AintersectsTcbufferCbuffer"; + + AintersectsTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..30f3679896 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer is always equal to the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class AlwaysEqTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTcbufferCbuffer"; + + AlwaysEqTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..ac3fc38be8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer is always not equal to the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class AlwaysNeTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTcbufferCbuffer"; + + AlwaysNeTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AtouchesTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AtouchesTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..7743f36132 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AtouchesTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer always touches the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class AtouchesTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AtouchesTcbufferCbuffer"; + + AtouchesTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EcontainsTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EcontainsTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..c1dcb96dfc --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EcontainsTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer ever contains the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class EcontainsTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EcontainsTcbufferCbuffer"; + + EcontainsTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EcoversTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EcoversTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..979b070b74 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EcoversTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer ever covers the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class EcoversTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EcoversTcbufferCbuffer"; + + EcoversTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EdisjointTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EdisjointTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..26e2138d17 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EdisjointTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer is ever disjoint from the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class EdisjointTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EdisjointTcbufferCbuffer"; + + EdisjointTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EintersectsTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EintersectsTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..9caf9e2b38 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EintersectsTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer ever intersects the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class EintersectsTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EintersectsTcbufferCbuffer"; + + EintersectsTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EtouchesTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EtouchesTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..6bd09cb6cc --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EtouchesTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer ever touches the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class EtouchesTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EtouchesTcbufferCbuffer"; + + EtouchesTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..aef5e48e10 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer is ever equal to the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class EverEqTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTcbufferCbuffer"; + + EverEqTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..06fda3aed8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tcbuffer is ever not equal to the static cbuffer, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class EverNeTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTcbufferCbuffer"; + + EverNeTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/NadTcbufferCbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/NadTcbufferCbufferLogicalFunction.hpp new file mode 100644 index 0000000000..d907348deb --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/NadTcbufferCbufferLogicalFunction.hpp @@ -0,0 +1,53 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nearest approach distance between the tcbuffer and a static cbuffer. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64) -> FLOAT64. + */ +class NadTcbufferCbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "NadTcbufferCbuffer"; + + NadTcbufferCbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AcontainsTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AcontainsTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..7ff60a048d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AcontainsTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AcontainsTcbufferCbufferLogicalFunction::AcontainsTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType AcontainsTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AcontainsTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AcontainsTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AcontainsTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "AcontainsTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AcontainsTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool AcontainsTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AcontainsTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AcontainsTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AcontainsTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAcontainsTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "AcontainsTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return AcontainsTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AcoversTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AcoversTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..db8812d25d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AcoversTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AcoversTcbufferCbufferLogicalFunction::AcoversTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType AcoversTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AcoversTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AcoversTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AcoversTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "AcoversTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AcoversTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool AcoversTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AcoversTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AcoversTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AcoversTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAcoversTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "AcoversTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return AcoversTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AdisjointTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AdisjointTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..388c2a0b11 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AdisjointTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AdisjointTcbufferCbufferLogicalFunction::AdisjointTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType AdisjointTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AdisjointTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AdisjointTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AdisjointTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "AdisjointTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AdisjointTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool AdisjointTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AdisjointTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AdisjointTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AdisjointTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAdisjointTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "AdisjointTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return AdisjointTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AintersectsTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AintersectsTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..bb82d18700 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AintersectsTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AintersectsTcbufferCbufferLogicalFunction::AintersectsTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType AintersectsTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AintersectsTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AintersectsTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AintersectsTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "AintersectsTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AintersectsTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool AintersectsTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AintersectsTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AintersectsTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AintersectsTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAintersectsTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "AintersectsTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return AintersectsTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..96cde90966 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTcbufferCbufferLogicalFunction::AlwaysEqTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType AlwaysEqTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "AlwaysEqTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AlwaysEqTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "AlwaysEqTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return AlwaysEqTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..8c68690933 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTcbufferCbufferLogicalFunction::AlwaysNeTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType AlwaysNeTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "AlwaysNeTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AlwaysNeTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "AlwaysNeTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return AlwaysNeTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AtouchesTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AtouchesTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..00d3e3c794 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AtouchesTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AtouchesTcbufferCbufferLogicalFunction::AtouchesTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType AtouchesTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AtouchesTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AtouchesTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AtouchesTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "AtouchesTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AtouchesTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool AtouchesTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AtouchesTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AtouchesTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AtouchesTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAtouchesTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "AtouchesTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return AtouchesTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 1d83d1dc98..dd42371f6f 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -350,6 +350,21 @@ add_plugin(AcontainsTcbufferGeo LogicalFunction nes-logical-operators AcontainsT add_plugin(NadTcbufferGeo LogicalFunction nes-logical-operators NadTcbufferGeoLogicalFunction.cpp) add_plugin(EdwithinTcbufferGeo LogicalFunction nes-logical-operators EdwithinTcbufferGeoLogicalFunction.cpp) add_plugin(AdwithinTcbufferGeo LogicalFunction nes-logical-operators AdwithinTcbufferGeoLogicalFunction.cpp) +add_plugin(EintersectsTcbufferCbuffer LogicalFunction nes-logical-operators EintersectsTcbufferCbufferLogicalFunction.cpp) +add_plugin(AintersectsTcbufferCbuffer LogicalFunction nes-logical-operators AintersectsTcbufferCbufferLogicalFunction.cpp) +add_plugin(EcoversTcbufferCbuffer LogicalFunction nes-logical-operators EcoversTcbufferCbufferLogicalFunction.cpp) +add_plugin(AcoversTcbufferCbuffer LogicalFunction nes-logical-operators AcoversTcbufferCbufferLogicalFunction.cpp) +add_plugin(EdisjointTcbufferCbuffer LogicalFunction nes-logical-operators EdisjointTcbufferCbufferLogicalFunction.cpp) +add_plugin(AdisjointTcbufferCbuffer LogicalFunction nes-logical-operators AdisjointTcbufferCbufferLogicalFunction.cpp) +add_plugin(EtouchesTcbufferCbuffer LogicalFunction nes-logical-operators EtouchesTcbufferCbufferLogicalFunction.cpp) +add_plugin(AtouchesTcbufferCbuffer LogicalFunction nes-logical-operators AtouchesTcbufferCbufferLogicalFunction.cpp) +add_plugin(EcontainsTcbufferCbuffer LogicalFunction nes-logical-operators EcontainsTcbufferCbufferLogicalFunction.cpp) +add_plugin(AcontainsTcbufferCbuffer LogicalFunction nes-logical-operators AcontainsTcbufferCbufferLogicalFunction.cpp) +add_plugin(EverEqTcbufferCbuffer LogicalFunction nes-logical-operators EverEqTcbufferCbufferLogicalFunction.cpp) +add_plugin(AlwaysEqTcbufferCbuffer LogicalFunction nes-logical-operators AlwaysEqTcbufferCbufferLogicalFunction.cpp) +add_plugin(EverNeTcbufferCbuffer LogicalFunction nes-logical-operators EverNeTcbufferCbufferLogicalFunction.cpp) +add_plugin(AlwaysNeTcbufferCbuffer LogicalFunction nes-logical-operators AlwaysNeTcbufferCbufferLogicalFunction.cpp) +add_plugin(NadTcbufferCbuffer LogicalFunction nes-logical-operators NadTcbufferCbufferLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EcontainsTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EcontainsTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..13e792f6d3 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EcontainsTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EcontainsTcbufferCbufferLogicalFunction::EcontainsTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType EcontainsTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EcontainsTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EcontainsTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EcontainsTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "EcontainsTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EcontainsTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool EcontainsTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EcontainsTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EcontainsTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EcontainsTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEcontainsTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "EcontainsTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return EcontainsTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EcoversTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EcoversTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..7fea846b75 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EcoversTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EcoversTcbufferCbufferLogicalFunction::EcoversTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType EcoversTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EcoversTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EcoversTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EcoversTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "EcoversTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EcoversTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool EcoversTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EcoversTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EcoversTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EcoversTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEcoversTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "EcoversTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return EcoversTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EdisjointTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EdisjointTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..daa391816d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EdisjointTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EdisjointTcbufferCbufferLogicalFunction::EdisjointTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType EdisjointTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EdisjointTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EdisjointTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EdisjointTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "EdisjointTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EdisjointTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool EdisjointTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EdisjointTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EdisjointTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EdisjointTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEdisjointTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "EdisjointTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return EdisjointTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EintersectsTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EintersectsTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..a0e7cbe116 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EintersectsTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EintersectsTcbufferCbufferLogicalFunction::EintersectsTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType EintersectsTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EintersectsTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EintersectsTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EintersectsTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "EintersectsTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EintersectsTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool EintersectsTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EintersectsTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EintersectsTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EintersectsTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEintersectsTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "EintersectsTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return EintersectsTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EtouchesTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EtouchesTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..5de03c5556 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EtouchesTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EtouchesTcbufferCbufferLogicalFunction::EtouchesTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType EtouchesTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EtouchesTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EtouchesTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EtouchesTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "EtouchesTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EtouchesTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool EtouchesTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EtouchesTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EtouchesTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EtouchesTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEtouchesTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "EtouchesTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return EtouchesTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..b2ec476c85 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTcbufferCbufferLogicalFunction::EverEqTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType EverEqTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "EverEqTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool EverEqTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EverEqTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "EverEqTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return EverEqTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..4a9fe1ec72 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTcbufferCbufferLogicalFunction::EverNeTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType EverNeTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "EverNeTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool EverNeTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EverNeTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "EverNeTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return EverNeTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/NadTcbufferCbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/NadTcbufferCbufferLogicalFunction.cpp new file mode 100644 index 0000000000..3f5787223a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/NadTcbufferCbufferLogicalFunction.cpp @@ -0,0 +1,116 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +NadTcbufferCbufferLogicalFunction::NadTcbufferCbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); +} + +DataType NadTcbufferCbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction NadTcbufferCbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector NadTcbufferCbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction NadTcbufferCbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "NadTcbufferCbufferLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view NadTcbufferCbufferLogicalFunction::getType() const { return NAME; } + +bool NadTcbufferCbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string NadTcbufferCbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction NadTcbufferCbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction NadTcbufferCbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterNadTcbufferCbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "NadTcbufferCbufferLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return NadTcbufferCbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AcontainsTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AcontainsTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..a73bc82985 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AcontainsTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AcontainsTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AcontainsTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AcoversTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AcoversTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..476f2bbfc1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AcoversTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AcoversTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AcoversTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AdisjointTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AdisjointTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..603c3e4ff0 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AdisjointTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AdisjointTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AdisjointTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AintersectsTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AintersectsTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..5bc44e7246 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AintersectsTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AintersectsTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AintersectsTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..a8f501c728 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..0b3cd9d6e8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AtouchesTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AtouchesTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..b2a1798964 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AtouchesTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AtouchesTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AtouchesTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EcontainsTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EcontainsTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..e6407b3c69 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EcontainsTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EcontainsTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + EcontainsTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EcoversTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EcoversTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..fd663a6119 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EcoversTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EcoversTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + EcoversTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EdisjointTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EdisjointTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..3ecde1f078 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EdisjointTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EdisjointTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + EdisjointTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EintersectsTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EintersectsTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..d6cca443dc --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EintersectsTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EintersectsTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + EintersectsTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EtouchesTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EtouchesTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..14f2eda15d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EtouchesTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EtouchesTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + EtouchesTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..873f6dc7fe --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..3a56d904c1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/NadTcbufferCbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/NadTcbufferCbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..29dc60eac4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/NadTcbufferCbufferPhysicalFunction.hpp @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class NadTcbufferCbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + NadTcbufferCbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AcontainsTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AcontainsTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..662bc2acc9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AcontainsTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AcontainsTcbufferCbufferPhysicalFunction::AcontainsTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal AcontainsTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = acontains_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAcontainsTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "AcontainsTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return AcontainsTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AcoversTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AcoversTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..0eaba43de5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AcoversTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AcoversTcbufferCbufferPhysicalFunction::AcoversTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal AcoversTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = acovers_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAcoversTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "AcoversTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return AcoversTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AdisjointTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AdisjointTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..16ca2ac2e4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AdisjointTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AdisjointTcbufferCbufferPhysicalFunction::AdisjointTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal AdisjointTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = adisjoint_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAdisjointTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "AdisjointTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return AdisjointTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AintersectsTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AintersectsTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..5b7158e668 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AintersectsTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AintersectsTcbufferCbufferPhysicalFunction::AintersectsTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal AintersectsTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = aintersects_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAintersectsTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "AintersectsTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return AintersectsTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..886379bb2c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AlwaysEqTcbufferCbufferPhysicalFunction::AlwaysEqTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal AlwaysEqTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = always_eq_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "AlwaysEqTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..acf39e8966 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AlwaysNeTcbufferCbufferPhysicalFunction::AlwaysNeTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal AlwaysNeTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = always_ne_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "AlwaysNeTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AtouchesTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AtouchesTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..196327aa50 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AtouchesTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AtouchesTcbufferCbufferPhysicalFunction::AtouchesTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal AtouchesTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = atouches_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAtouchesTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "AtouchesTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return AtouchesTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 33e9b9a416..8a7351169f 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -349,6 +349,21 @@ add_plugin(AcontainsTcbufferGeo PhysicalFunction nes-physical-operators Acontain add_plugin(NadTcbufferGeo PhysicalFunction nes-physical-operators NadTcbufferGeoPhysicalFunction.cpp) add_plugin(EdwithinTcbufferGeo PhysicalFunction nes-physical-operators EdwithinTcbufferGeoPhysicalFunction.cpp) add_plugin(AdwithinTcbufferGeo PhysicalFunction nes-physical-operators AdwithinTcbufferGeoPhysicalFunction.cpp) +add_plugin(EintersectsTcbufferCbuffer PhysicalFunction nes-physical-operators EintersectsTcbufferCbufferPhysicalFunction.cpp) +add_plugin(AintersectsTcbufferCbuffer PhysicalFunction nes-physical-operators AintersectsTcbufferCbufferPhysicalFunction.cpp) +add_plugin(EcoversTcbufferCbuffer PhysicalFunction nes-physical-operators EcoversTcbufferCbufferPhysicalFunction.cpp) +add_plugin(AcoversTcbufferCbuffer PhysicalFunction nes-physical-operators AcoversTcbufferCbufferPhysicalFunction.cpp) +add_plugin(EdisjointTcbufferCbuffer PhysicalFunction nes-physical-operators EdisjointTcbufferCbufferPhysicalFunction.cpp) +add_plugin(AdisjointTcbufferCbuffer PhysicalFunction nes-physical-operators AdisjointTcbufferCbufferPhysicalFunction.cpp) +add_plugin(EtouchesTcbufferCbuffer PhysicalFunction nes-physical-operators EtouchesTcbufferCbufferPhysicalFunction.cpp) +add_plugin(AtouchesTcbufferCbuffer PhysicalFunction nes-physical-operators AtouchesTcbufferCbufferPhysicalFunction.cpp) +add_plugin(EcontainsTcbufferCbuffer PhysicalFunction nes-physical-operators EcontainsTcbufferCbufferPhysicalFunction.cpp) +add_plugin(AcontainsTcbufferCbuffer PhysicalFunction nes-physical-operators AcontainsTcbufferCbufferPhysicalFunction.cpp) +add_plugin(EverEqTcbufferCbuffer PhysicalFunction nes-physical-operators EverEqTcbufferCbufferPhysicalFunction.cpp) +add_plugin(AlwaysEqTcbufferCbuffer PhysicalFunction nes-physical-operators AlwaysEqTcbufferCbufferPhysicalFunction.cpp) +add_plugin(EverNeTcbufferCbuffer PhysicalFunction nes-physical-operators EverNeTcbufferCbufferPhysicalFunction.cpp) +add_plugin(AlwaysNeTcbufferCbuffer PhysicalFunction nes-physical-operators AlwaysNeTcbufferCbufferPhysicalFunction.cpp) +add_plugin(NadTcbufferCbuffer PhysicalFunction nes-physical-operators NadTcbufferCbufferPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EcontainsTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EcontainsTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..dc7704cda5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EcontainsTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EcontainsTcbufferCbufferPhysicalFunction::EcontainsTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal EcontainsTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = econtains_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEcontainsTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "EcontainsTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return EcontainsTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EcoversTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EcoversTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..81e1957626 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EcoversTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EcoversTcbufferCbufferPhysicalFunction::EcoversTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal EcoversTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = ecovers_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEcoversTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "EcoversTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return EcoversTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EdisjointTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EdisjointTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..4b0f9b46a3 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EdisjointTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EdisjointTcbufferCbufferPhysicalFunction::EdisjointTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal EdisjointTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = edisjoint_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEdisjointTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "EdisjointTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return EdisjointTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EintersectsTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EintersectsTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..7036b9fc2d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EintersectsTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EintersectsTcbufferCbufferPhysicalFunction::EintersectsTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal EintersectsTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = eintersects_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEintersectsTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "EintersectsTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return EintersectsTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EtouchesTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EtouchesTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..b90b4de1ae --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EtouchesTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EtouchesTcbufferCbufferPhysicalFunction::EtouchesTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal EtouchesTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = etouches_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEtouchesTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "EtouchesTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return EtouchesTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..d51279857e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EverEqTcbufferCbufferPhysicalFunction::EverEqTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal EverEqTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = ever_eq_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "EverEqTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return EverEqTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..fe2abeb2da --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EverNeTcbufferCbufferPhysicalFunction::EverNeTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal EverNeTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + int r = ever_ne_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "EverNeTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return EverNeTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/NadTcbufferCbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/NadTcbufferCbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..011a4cf277 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/NadTcbufferCbufferPhysicalFunction.cpp @@ -0,0 +1,110 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +NadTcbufferCbufferPhysicalFunction::NadTcbufferCbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); +} + +VarVal NadTcbufferCbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts, + double lon2, double lat2, double r2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + // Build tcbuffer instant from (lon1,lat1,r1,ts) + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* pt1_gs = geom_in(pt1.c_str(), -1); + if (!pt1_gs) return 0.0; + Cbuffer* cb1 = cbuffer_make(pt1_gs, r1); + free(pt1_gs); + if (!cb1) return 0.0; + Temporal* tcb_inst = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts); + free(cb1); + if (!tcb_inst) return 0.0; + // Build static cbuffer from (lon2,lat2,r2) + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* pt2_gs = geom_in(pt2.c_str(), -1); + if (!pt2_gs) { free(tcb_inst); return 0.0; } + Cbuffer* cb2 = cbuffer_make(pt2_gs, r2); + free(pt2_gs); + if (!cb2) { free(tcb_inst); return 0.0; } + double r = nad_tcbuffer_cbuffer(tcb_inst, cb2); + free(tcb_inst); + free(cb2); + return r; + } catch (const std::exception&) { return -1.0; } + }, + lon1, lat1, r1, ts, lon2, lat2, r2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterNadTcbufferCbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "NadTcbufferCbufferPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return NadTcbufferCbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index b054846852..a6c94ca2a0 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -820,6 +820,21 @@ ACONTAINS_TCBUFFER_GEO: 'ACONTAINS_TCBUFFER_GEO' | 'acontains_tcbuffer_geo'; NAD_TCBUFFER_GEO: 'NAD_TCBUFFER_GEO' | 'nad_tcbuffer_geo'; EDWITHIN_TCBUFFER_GEO: 'EDWITHIN_TCBUFFER_GEO' | 'edwithin_tcbuffer_geo'; ADWITHIN_TCBUFFER_GEO: 'ADWITHIN_TCBUFFER_GEO' | 'adwithin_tcbuffer_geo'; +EINTERSECTS_TCBUFFER_CBUFFER: 'EINTERSECTS_TCBUFFER_CBUFFER' | 'eintersects_tcbuffer_cbuffer'; +AINTERSECTS_TCBUFFER_CBUFFER: 'AINTERSECTS_TCBUFFER_CBUFFER' | 'aintersects_tcbuffer_cbuffer'; +ECOVERS_TCBUFFER_CBUFFER: 'ECOVERS_TCBUFFER_CBUFFER' | 'ecovers_tcbuffer_cbuffer'; +ACOVERS_TCBUFFER_CBUFFER: 'ACOVERS_TCBUFFER_CBUFFER' | 'acovers_tcbuffer_cbuffer'; +EDISJOINT_TCBUFFER_CBUFFER: 'EDISJOINT_TCBUFFER_CBUFFER' | 'edisjoint_tcbuffer_cbuffer'; +ADISJOINT_TCBUFFER_CBUFFER: 'ADISJOINT_TCBUFFER_CBUFFER' | 'adisjoint_tcbuffer_cbuffer'; +ETOUCHES_TCBUFFER_CBUFFER: 'ETOUCHES_TCBUFFER_CBUFFER' | 'etouches_tcbuffer_cbuffer'; +ATOUCHES_TCBUFFER_CBUFFER: 'ATOUCHES_TCBUFFER_CBUFFER' | 'atouches_tcbuffer_cbuffer'; +ECONTAINS_TCBUFFER_CBUFFER: 'ECONTAINS_TCBUFFER_CBUFFER' | 'econtains_tcbuffer_cbuffer'; +ACONTAINS_TCBUFFER_CBUFFER: 'ACONTAINS_TCBUFFER_CBUFFER' | 'acontains_tcbuffer_cbuffer'; +EVER_EQ_TCBUFFER_CBUFFER: 'EVER_EQ_TCBUFFER_CBUFFER' | 'ever_eq_tcbuffer_cbuffer'; +ALWAYS_EQ_TCBUFFER_CBUFFER: 'ALWAYS_EQ_TCBUFFER_CBUFFER' | 'always_eq_tcbuffer_cbuffer'; +EVER_NE_TCBUFFER_CBUFFER: 'EVER_NE_TCBUFFER_CBUFFER' | 'ever_ne_tcbuffer_cbuffer'; +ALWAYS_NE_TCBUFFER_CBUFFER: 'ALWAYS_NE_TCBUFFER_CBUFFER' | 'always_ne_tcbuffer_cbuffer'; +NAD_TCBUFFER_CBUFFER: 'NAD_TCBUFFER_CBUFFER' | 'nad_tcbuffer_cbuffer'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index ae848f26ce..45b6756be6 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -401,6 +401,21 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -9465,6 +9480,216 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(AdwithinTcbufferGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); } /* END CODEGEN PARSER GLUE: ADWITHIN_TCBUFFER_GEO */ + case AntlrSQLParser::EINTERSECTS_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "EintersectsTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(EintersectsTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: EINTERSECTS_TCBUFFER_CBUFFER */ + case AntlrSQLParser::AINTERSECTS_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "AintersectsTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(AintersectsTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: AINTERSECTS_TCBUFFER_CBUFFER */ + case AntlrSQLParser::ECOVERS_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "EcoversTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(EcoversTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ECOVERS_TCBUFFER_CBUFFER */ + case AntlrSQLParser::ACOVERS_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "AcoversTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(AcoversTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ACOVERS_TCBUFFER_CBUFFER */ + case AntlrSQLParser::EDISJOINT_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "EdisjointTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(EdisjointTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: EDISJOINT_TCBUFFER_CBUFFER */ + case AntlrSQLParser::ADISJOINT_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "AdisjointTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(AdisjointTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ADISJOINT_TCBUFFER_CBUFFER */ + case AntlrSQLParser::ETOUCHES_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "EtouchesTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(EtouchesTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ETOUCHES_TCBUFFER_CBUFFER */ + case AntlrSQLParser::ATOUCHES_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "AtouchesTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(AtouchesTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ATOUCHES_TCBUFFER_CBUFFER */ + case AntlrSQLParser::ECONTAINS_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "EcontainsTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(EcontainsTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ECONTAINS_TCBUFFER_CBUFFER */ + case AntlrSQLParser::ACONTAINS_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "AcontainsTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(AcontainsTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ACONTAINS_TCBUFFER_CBUFFER */ + case AntlrSQLParser::EVER_EQ_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "EverEqTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(EverEqTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_TCBUFFER_CBUFFER */ + case AntlrSQLParser::ALWAYS_EQ_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "AlwaysEqTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(AlwaysEqTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TCBUFFER_CBUFFER */ + case AntlrSQLParser::EVER_NE_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "EverNeTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(EverNeTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_TCBUFFER_CBUFFER */ + case AntlrSQLParser::ALWAYS_NE_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "AlwaysNeTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(AlwaysNeTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TCBUFFER_CBUFFER */ + case AntlrSQLParser::NAD_TCBUFFER_CBUFFER: { + PRECONDITION(ctx->functionParam().size() == 7, + "NadTcbufferCbuffer requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(NadTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: NAD_TCBUFFER_CBUFFER */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 4afd041e6ab16ac13b2aee0fa92ca1e81f7e4f62 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 06:36:12 +0200 Subject: [PATCH 64/86] feat(meos): add tcbuffer_tcbuffer per-event scalar operators (W116) Wires twelve operators over two tcbuffer instants using a new 8-arg all-numeric pattern (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64) -> FLOAT64. The physical functions build two tcbuffer instants independently then delegate to the MEOS kernel. Operators: EVER_EQ/ALWAYS_EQ, EVER_NE/ALWAYS_NE, EINTERSECTS/AINTERSECTS, ECOVERS/ACOVERS, ADISJOINT, ETOUCHES/ATOUCHES _TCBUFFER_TCBUFFER, and NAD_TCBUFFER_TCBUFFER. --- ...AcoversTcbufferTcbufferLogicalFunction.hpp | 54 +++++ ...isjointTcbufferTcbufferLogicalFunction.hpp | 54 +++++ ...ersectsTcbufferTcbufferLogicalFunction.hpp | 54 +++++ ...lwaysEqTcbufferTcbufferLogicalFunction.hpp | 54 +++++ ...lwaysNeTcbufferTcbufferLogicalFunction.hpp | 54 +++++ ...touchesTcbufferTcbufferLogicalFunction.hpp | 54 +++++ ...EcoversTcbufferTcbufferLogicalFunction.hpp | 54 +++++ ...ersectsTcbufferTcbufferLogicalFunction.hpp | 54 +++++ ...touchesTcbufferTcbufferLogicalFunction.hpp | 54 +++++ .../EverEqTcbufferTcbufferLogicalFunction.hpp | 54 +++++ .../EverNeTcbufferTcbufferLogicalFunction.hpp | 54 +++++ .../NadTcbufferTcbufferLogicalFunction.hpp | 54 +++++ ...AcoversTcbufferTcbufferLogicalFunction.cpp | 118 +++++++++++ ...isjointTcbufferTcbufferLogicalFunction.cpp | 118 +++++++++++ ...ersectsTcbufferTcbufferLogicalFunction.cpp | 118 +++++++++++ ...lwaysEqTcbufferTcbufferLogicalFunction.cpp | 118 +++++++++++ ...lwaysNeTcbufferTcbufferLogicalFunction.cpp | 118 +++++++++++ ...touchesTcbufferTcbufferLogicalFunction.cpp | 118 +++++++++++ .../src/Functions/Meos/CMakeLists.txt | 12 ++ ...EcoversTcbufferTcbufferLogicalFunction.cpp | 118 +++++++++++ ...ersectsTcbufferTcbufferLogicalFunction.cpp | 118 +++++++++++ ...touchesTcbufferTcbufferLogicalFunction.cpp | 118 +++++++++++ .../EverEqTcbufferTcbufferLogicalFunction.cpp | 118 +++++++++++ .../EverNeTcbufferTcbufferLogicalFunction.cpp | 118 +++++++++++ .../NadTcbufferTcbufferLogicalFunction.cpp | 118 +++++++++++ ...coversTcbufferTcbufferPhysicalFunction.hpp | 37 ++++ ...sjointTcbufferTcbufferPhysicalFunction.hpp | 37 ++++ ...rsectsTcbufferTcbufferPhysicalFunction.hpp | 37 ++++ ...waysEqTcbufferTcbufferPhysicalFunction.hpp | 37 ++++ ...waysNeTcbufferTcbufferPhysicalFunction.hpp | 37 ++++ ...ouchesTcbufferTcbufferPhysicalFunction.hpp | 37 ++++ ...coversTcbufferTcbufferPhysicalFunction.hpp | 37 ++++ ...rsectsTcbufferTcbufferPhysicalFunction.hpp | 37 ++++ ...ouchesTcbufferTcbufferPhysicalFunction.hpp | 37 ++++ ...EverEqTcbufferTcbufferPhysicalFunction.hpp | 37 ++++ ...EverNeTcbufferTcbufferPhysicalFunction.hpp | 37 ++++ .../NadTcbufferTcbufferPhysicalFunction.hpp | 37 ++++ ...coversTcbufferTcbufferPhysicalFunction.cpp | 112 ++++++++++ ...sjointTcbufferTcbufferPhysicalFunction.cpp | 112 ++++++++++ ...rsectsTcbufferTcbufferPhysicalFunction.cpp | 112 ++++++++++ ...waysEqTcbufferTcbufferPhysicalFunction.cpp | 112 ++++++++++ ...waysNeTcbufferTcbufferPhysicalFunction.cpp | 112 ++++++++++ ...ouchesTcbufferTcbufferPhysicalFunction.cpp | 112 ++++++++++ .../src/Functions/Meos/CMakeLists.txt | 12 ++ ...coversTcbufferTcbufferPhysicalFunction.cpp | 112 ++++++++++ ...rsectsTcbufferTcbufferPhysicalFunction.cpp | 112 ++++++++++ ...ouchesTcbufferTcbufferPhysicalFunction.cpp | 112 ++++++++++ ...EverEqTcbufferTcbufferPhysicalFunction.cpp | 112 ++++++++++ ...EverNeTcbufferTcbufferPhysicalFunction.cpp | 112 ++++++++++ .../NadTcbufferTcbufferPhysicalFunction.cpp | 112 ++++++++++ nes-sql-parser/AntlrSQL.g4 | 14 +- .../src/AntlrSQLQueryPlanCreator.cpp | 192 ++++++++++++++++++ 52 files changed, 4081 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AcoversTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AdisjointTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AintersectsTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AtouchesTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EcoversTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EintersectsTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EtouchesTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/NadTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AcoversTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AdisjointTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AintersectsTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AtouchesTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EcoversTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EintersectsTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EtouchesTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/NadTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AcoversTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AdisjointTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AintersectsTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AtouchesTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EcoversTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EintersectsTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EtouchesTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/NadTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AcoversTcbufferTcbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AdisjointTcbufferTcbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AintersectsTcbufferTcbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTcbufferTcbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTcbufferTcbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AtouchesTcbufferTcbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EcoversTcbufferTcbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EintersectsTcbufferTcbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EtouchesTcbufferTcbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTcbufferTcbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTcbufferTcbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/NadTcbufferTcbufferPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AcoversTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AcoversTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..460443d9ee --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AcoversTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the first tcbuffer instant always covers the second, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class AcoversTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AcoversTcbufferTcbuffer"; + + AcoversTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AdisjointTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AdisjointTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..8555ac5974 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AdisjointTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tcbuffer instants are always disjoint, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class AdisjointTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AdisjointTcbufferTcbuffer"; + + AdisjointTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AintersectsTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AintersectsTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..826b06ed8f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AintersectsTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tcbuffer instants always intersect, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class AintersectsTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AintersectsTcbufferTcbuffer"; + + AintersectsTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..dfd2fa0236 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tcbuffer instants are always equal, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class AlwaysEqTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTcbufferTcbuffer"; + + AlwaysEqTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..7e30c5d3b6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tcbuffer instants are always not equal, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class AlwaysNeTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTcbufferTcbuffer"; + + AlwaysNeTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AtouchesTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AtouchesTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..09466cc342 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AtouchesTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tcbuffer instants always touch, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class AtouchesTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AtouchesTcbufferTcbuffer"; + + AtouchesTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EcoversTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EcoversTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..dfd6c46d73 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EcoversTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the first tcbuffer instant ever covers the second, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class EcoversTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EcoversTcbufferTcbuffer"; + + EcoversTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EintersectsTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EintersectsTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..9728a93196 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EintersectsTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tcbuffer instants ever intersect, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class EintersectsTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EintersectsTcbufferTcbuffer"; + + EintersectsTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EtouchesTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EtouchesTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..de01556eae --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EtouchesTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tcbuffer instants ever touch, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class EtouchesTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EtouchesTcbufferTcbuffer"; + + EtouchesTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..24197ef994 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tcbuffer instants are ever equal, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class EverEqTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTcbufferTcbuffer"; + + EverEqTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..ae466f1ed0 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tcbuffer instants are ever not equal, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class EverNeTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTcbufferTcbuffer"; + + EverNeTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/NadTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/NadTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..37b1182ebd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/NadTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nearest approach distance between two tcbuffer instants. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class NadTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "NadTcbufferTcbuffer"; + + NadTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AcoversTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AcoversTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..afced174f2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AcoversTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AcoversTcbufferTcbufferLogicalFunction::AcoversTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); +} + +DataType AcoversTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AcoversTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AcoversTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AcoversTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "AcoversTcbufferTcbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AcoversTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool AcoversTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AcoversTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AcoversTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AcoversTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAcoversTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "AcoversTcbufferTcbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return AcoversTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AdisjointTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AdisjointTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..7667e268f2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AdisjointTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AdisjointTcbufferTcbufferLogicalFunction::AdisjointTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); +} + +DataType AdisjointTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AdisjointTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AdisjointTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AdisjointTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "AdisjointTcbufferTcbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AdisjointTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool AdisjointTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AdisjointTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AdisjointTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AdisjointTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAdisjointTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "AdisjointTcbufferTcbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return AdisjointTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AintersectsTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AintersectsTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..333ce45585 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AintersectsTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AintersectsTcbufferTcbufferLogicalFunction::AintersectsTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); +} + +DataType AintersectsTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AintersectsTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AintersectsTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AintersectsTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "AintersectsTcbufferTcbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AintersectsTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool AintersectsTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AintersectsTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AintersectsTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AintersectsTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAintersectsTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "AintersectsTcbufferTcbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return AintersectsTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..69b0c8aa95 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTcbufferTcbufferLogicalFunction::AlwaysEqTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); +} + +DataType AlwaysEqTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "AlwaysEqTcbufferTcbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysEqTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "AlwaysEqTcbufferTcbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return AlwaysEqTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..08b859b984 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTcbufferTcbufferLogicalFunction::AlwaysNeTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); +} + +DataType AlwaysNeTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "AlwaysNeTcbufferTcbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysNeTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "AlwaysNeTcbufferTcbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return AlwaysNeTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AtouchesTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AtouchesTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..93e8cd9f52 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AtouchesTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AtouchesTcbufferTcbufferLogicalFunction::AtouchesTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); +} + +DataType AtouchesTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AtouchesTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AtouchesTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AtouchesTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "AtouchesTcbufferTcbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AtouchesTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool AtouchesTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AtouchesTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AtouchesTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AtouchesTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAtouchesTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "AtouchesTcbufferTcbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return AtouchesTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index dd42371f6f..6ec03bb757 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -365,6 +365,18 @@ add_plugin(AlwaysEqTcbufferCbuffer LogicalFunction nes-logical-operators AlwaysE add_plugin(EverNeTcbufferCbuffer LogicalFunction nes-logical-operators EverNeTcbufferCbufferLogicalFunction.cpp) add_plugin(AlwaysNeTcbufferCbuffer LogicalFunction nes-logical-operators AlwaysNeTcbufferCbufferLogicalFunction.cpp) add_plugin(NadTcbufferCbuffer LogicalFunction nes-logical-operators NadTcbufferCbufferLogicalFunction.cpp) +add_plugin(EverEqTcbufferTcbuffer LogicalFunction nes-logical-operators EverEqTcbufferTcbufferLogicalFunction.cpp) +add_plugin(AlwaysEqTcbufferTcbuffer LogicalFunction nes-logical-operators AlwaysEqTcbufferTcbufferLogicalFunction.cpp) +add_plugin(EverNeTcbufferTcbuffer LogicalFunction nes-logical-operators EverNeTcbufferTcbufferLogicalFunction.cpp) +add_plugin(AlwaysNeTcbufferTcbuffer LogicalFunction nes-logical-operators AlwaysNeTcbufferTcbufferLogicalFunction.cpp) +add_plugin(EintersectsTcbufferTcbuffer LogicalFunction nes-logical-operators EintersectsTcbufferTcbufferLogicalFunction.cpp) +add_plugin(AintersectsTcbufferTcbuffer LogicalFunction nes-logical-operators AintersectsTcbufferTcbufferLogicalFunction.cpp) +add_plugin(EcoversTcbufferTcbuffer LogicalFunction nes-logical-operators EcoversTcbufferTcbufferLogicalFunction.cpp) +add_plugin(AcoversTcbufferTcbuffer LogicalFunction nes-logical-operators AcoversTcbufferTcbufferLogicalFunction.cpp) +add_plugin(AdisjointTcbufferTcbuffer LogicalFunction nes-logical-operators AdisjointTcbufferTcbufferLogicalFunction.cpp) +add_plugin(EtouchesTcbufferTcbuffer LogicalFunction nes-logical-operators EtouchesTcbufferTcbufferLogicalFunction.cpp) +add_plugin(AtouchesTcbufferTcbuffer LogicalFunction nes-logical-operators AtouchesTcbufferTcbufferLogicalFunction.cpp) +add_plugin(NadTcbufferTcbuffer LogicalFunction nes-logical-operators NadTcbufferTcbufferLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EcoversTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EcoversTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..8318ad7d09 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EcoversTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EcoversTcbufferTcbufferLogicalFunction::EcoversTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); +} + +DataType EcoversTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EcoversTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EcoversTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EcoversTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "EcoversTcbufferTcbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EcoversTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool EcoversTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EcoversTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EcoversTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EcoversTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEcoversTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "EcoversTcbufferTcbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return EcoversTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EintersectsTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EintersectsTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..f28607d1a3 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EintersectsTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EintersectsTcbufferTcbufferLogicalFunction::EintersectsTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); +} + +DataType EintersectsTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EintersectsTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EintersectsTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EintersectsTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "EintersectsTcbufferTcbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EintersectsTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool EintersectsTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EintersectsTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EintersectsTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EintersectsTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEintersectsTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "EintersectsTcbufferTcbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return EintersectsTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EtouchesTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EtouchesTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..7c8087753d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EtouchesTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EtouchesTcbufferTcbufferLogicalFunction::EtouchesTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); +} + +DataType EtouchesTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EtouchesTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EtouchesTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EtouchesTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "EtouchesTcbufferTcbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EtouchesTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool EtouchesTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EtouchesTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EtouchesTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EtouchesTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEtouchesTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "EtouchesTcbufferTcbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return EtouchesTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..5de429ba45 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTcbufferTcbufferLogicalFunction::EverEqTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); +} + +DataType EverEqTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "EverEqTcbufferTcbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool EverEqTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverEqTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "EverEqTcbufferTcbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return EverEqTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..0ed031bbe2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTcbufferTcbufferLogicalFunction::EverNeTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); +} + +DataType EverNeTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "EverNeTcbufferTcbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool EverNeTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverNeTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "EverNeTcbufferTcbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return EverNeTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/NadTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/NadTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..abf97eb658 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/NadTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +NadTcbufferTcbufferLogicalFunction::NadTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); +} + +DataType NadTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction NadTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector NadTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction NadTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "NadTcbufferTcbufferLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view NadTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool NadTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string NadTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction NadTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction NadTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterNadTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "NadTcbufferTcbufferLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return NadTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AcoversTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AcoversTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..cac2f7aaa0 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AcoversTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AcoversTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AcoversTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AdisjointTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AdisjointTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..3b0c4c1d0f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AdisjointTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AdisjointTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AdisjointTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AintersectsTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AintersectsTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..1bea980358 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AintersectsTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AintersectsTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AintersectsTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..0729d3718d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..19395bb0f1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AtouchesTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AtouchesTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..f1d60816f4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AtouchesTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AtouchesTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AtouchesTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EcoversTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EcoversTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..ebd234cb88 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EcoversTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EcoversTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + EcoversTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EintersectsTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EintersectsTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..d2b3e01556 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EintersectsTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EintersectsTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + EintersectsTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EtouchesTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EtouchesTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..791dd19e8c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EtouchesTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EtouchesTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + EtouchesTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..8fef36a992 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..28318c6b8b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/NadTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/NadTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..9de7220367 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/NadTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class NadTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + NadTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AcoversTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AcoversTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..b3b62e4503 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AcoversTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AcoversTcbufferTcbufferPhysicalFunction::AcoversTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AcoversTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + int r = acovers_tcbuffer_tcbuffer(tcb1, tcb2); + free(tcb1); free(tcb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAcoversTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "AcoversTcbufferTcbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return AcoversTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AdisjointTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AdisjointTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..99b5187524 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AdisjointTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AdisjointTcbufferTcbufferPhysicalFunction::AdisjointTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AdisjointTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + int r = adisjoint_tcbuffer_tcbuffer(tcb1, tcb2); + free(tcb1); free(tcb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAdisjointTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "AdisjointTcbufferTcbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return AdisjointTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AintersectsTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AintersectsTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..ffec1430f4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AintersectsTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AintersectsTcbufferTcbufferPhysicalFunction::AintersectsTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AintersectsTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + int r = aintersects_tcbuffer_tcbuffer(tcb1, tcb2); + free(tcb1); free(tcb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAintersectsTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "AintersectsTcbufferTcbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return AintersectsTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..acd2036781 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AlwaysEqTcbufferTcbufferPhysicalFunction::AlwaysEqTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AlwaysEqTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + int r = always_eq_tcbuffer_tcbuffer(tcb1, tcb2); + free(tcb1); free(tcb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "AlwaysEqTcbufferTcbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..e142ca34b0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AlwaysNeTcbufferTcbufferPhysicalFunction::AlwaysNeTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AlwaysNeTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + int r = always_ne_tcbuffer_tcbuffer(tcb1, tcb2); + free(tcb1); free(tcb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "AlwaysNeTcbufferTcbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AtouchesTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AtouchesTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..9c77f7d23a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AtouchesTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AtouchesTcbufferTcbufferPhysicalFunction::AtouchesTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AtouchesTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + int r = atouches_tcbuffer_tcbuffer(tcb1, tcb2); + free(tcb1); free(tcb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAtouchesTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "AtouchesTcbufferTcbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return AtouchesTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 8a7351169f..9873b4aa00 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -364,6 +364,18 @@ add_plugin(AlwaysEqTcbufferCbuffer PhysicalFunction nes-physical-operators Alway add_plugin(EverNeTcbufferCbuffer PhysicalFunction nes-physical-operators EverNeTcbufferCbufferPhysicalFunction.cpp) add_plugin(AlwaysNeTcbufferCbuffer PhysicalFunction nes-physical-operators AlwaysNeTcbufferCbufferPhysicalFunction.cpp) add_plugin(NadTcbufferCbuffer PhysicalFunction nes-physical-operators NadTcbufferCbufferPhysicalFunction.cpp) +add_plugin(EverEqTcbufferTcbuffer PhysicalFunction nes-physical-operators EverEqTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(AlwaysEqTcbufferTcbuffer PhysicalFunction nes-physical-operators AlwaysEqTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(EverNeTcbufferTcbuffer PhysicalFunction nes-physical-operators EverNeTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(AlwaysNeTcbufferTcbuffer PhysicalFunction nes-physical-operators AlwaysNeTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(EintersectsTcbufferTcbuffer PhysicalFunction nes-physical-operators EintersectsTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(AintersectsTcbufferTcbuffer PhysicalFunction nes-physical-operators AintersectsTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(EcoversTcbufferTcbuffer PhysicalFunction nes-physical-operators EcoversTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(AcoversTcbufferTcbuffer PhysicalFunction nes-physical-operators AcoversTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(AdisjointTcbufferTcbuffer PhysicalFunction nes-physical-operators AdisjointTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(EtouchesTcbufferTcbuffer PhysicalFunction nes-physical-operators EtouchesTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(AtouchesTcbufferTcbuffer PhysicalFunction nes-physical-operators AtouchesTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(NadTcbufferTcbuffer PhysicalFunction nes-physical-operators NadTcbufferTcbufferPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EcoversTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EcoversTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..7aac08ea8c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EcoversTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EcoversTcbufferTcbufferPhysicalFunction::EcoversTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EcoversTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + int r = ecovers_tcbuffer_tcbuffer(tcb1, tcb2); + free(tcb1); free(tcb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEcoversTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "EcoversTcbufferTcbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return EcoversTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EintersectsTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EintersectsTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..b0adf16a3f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EintersectsTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EintersectsTcbufferTcbufferPhysicalFunction::EintersectsTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EintersectsTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + int r = eintersects_tcbuffer_tcbuffer(tcb1, tcb2); + free(tcb1); free(tcb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEintersectsTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "EintersectsTcbufferTcbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return EintersectsTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EtouchesTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EtouchesTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..987ae7c18c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EtouchesTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EtouchesTcbufferTcbufferPhysicalFunction::EtouchesTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EtouchesTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + int r = etouches_tcbuffer_tcbuffer(tcb1, tcb2); + free(tcb1); free(tcb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEtouchesTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "EtouchesTcbufferTcbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return EtouchesTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..7f3fc0d69d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EverEqTcbufferTcbufferPhysicalFunction::EverEqTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EverEqTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + int r = ever_eq_tcbuffer_tcbuffer(tcb1, tcb2); + free(tcb1); free(tcb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "EverEqTcbufferTcbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return EverEqTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..10f7ece074 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EverNeTcbufferTcbufferPhysicalFunction::EverNeTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EverNeTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + int r = ever_ne_tcbuffer_tcbuffer(tcb1, tcb2); + free(tcb1); free(tcb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "EverNeTcbufferTcbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return EverNeTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/NadTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/NadTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..d55646d9de --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/NadTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +NadTcbufferTcbufferPhysicalFunction::NadTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal NadTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + double r = nad_tcbuffer_tcbuffer(tcb1, tcb2); + free(tcb1); free(tcb2); + return r; + } catch (const std::exception&) { return -1.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterNadTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "NadTcbufferTcbufferPhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return NadTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index a6c94ca2a0..57092f5857 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -835,6 +835,18 @@ ALWAYS_EQ_TCBUFFER_CBUFFER: 'ALWAYS_EQ_TCBUFFER_CBUFFER' | 'always_eq_tcbuffer_c EVER_NE_TCBUFFER_CBUFFER: 'EVER_NE_TCBUFFER_CBUFFER' | 'ever_ne_tcbuffer_cbuffer'; ALWAYS_NE_TCBUFFER_CBUFFER: 'ALWAYS_NE_TCBUFFER_CBUFFER' | 'always_ne_tcbuffer_cbuffer'; NAD_TCBUFFER_CBUFFER: 'NAD_TCBUFFER_CBUFFER' | 'nad_tcbuffer_cbuffer'; +EVER_EQ_TCBUFFER_TCBUFFER: 'EVER_EQ_TCBUFFER_TCBUFFER' | 'ever_eq_tcbuffer_tcbuffer'; +ALWAYS_EQ_TCBUFFER_TCBUFFER: 'ALWAYS_EQ_TCBUFFER_TCBUFFER' | 'always_eq_tcbuffer_tcbuffer'; +EVER_NE_TCBUFFER_TCBUFFER: 'EVER_NE_TCBUFFER_TCBUFFER' | 'ever_ne_tcbuffer_tcbuffer'; +ALWAYS_NE_TCBUFFER_TCBUFFER: 'ALWAYS_NE_TCBUFFER_TCBUFFER' | 'always_ne_tcbuffer_tcbuffer'; +EINTERSECTS_TCBUFFER_TCBUFFER: 'EINTERSECTS_TCBUFFER_TCBUFFER' | 'eintersects_tcbuffer_tcbuffer'; +AINTERSECTS_TCBUFFER_TCBUFFER: 'AINTERSECTS_TCBUFFER_TCBUFFER' | 'aintersects_tcbuffer_tcbuffer'; +ECOVERS_TCBUFFER_TCBUFFER: 'ECOVERS_TCBUFFER_TCBUFFER' | 'ecovers_tcbuffer_tcbuffer'; +ACOVERS_TCBUFFER_TCBUFFER: 'ACOVERS_TCBUFFER_TCBUFFER' | 'acovers_tcbuffer_tcbuffer'; +ADISJOINT_TCBUFFER_TCBUFFER: 'ADISJOINT_TCBUFFER_TCBUFFER' | 'adisjoint_tcbuffer_tcbuffer'; +ETOUCHES_TCBUFFER_TCBUFFER: 'ETOUCHES_TCBUFFER_TCBUFFER' | 'etouches_tcbuffer_tcbuffer'; +ATOUCHES_TCBUFFER_TCBUFFER: 'ATOUCHES_TCBUFFER_TCBUFFER' | 'atouches_tcbuffer_tcbuffer'; +NAD_TCBUFFER_TCBUFFER: 'NAD_TCBUFFER_TCBUFFER' | 'nad_tcbuffer_tcbuffer'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 45b6756be6..754015f335 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -416,6 +416,18 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -9690,6 +9702,186 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(NadTcbufferCbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); } /* END CODEGEN PARSER GLUE: NAD_TCBUFFER_CBUFFER */ + case AntlrSQLParser::EVER_EQ_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 8, + "EverEqTcbufferTcbuffer requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(EverEqTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::ALWAYS_EQ_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 8, + "AlwaysEqTcbufferTcbuffer requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(AlwaysEqTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::EVER_NE_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 8, + "EverNeTcbufferTcbuffer requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(EverNeTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::ALWAYS_NE_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 8, + "AlwaysNeTcbufferTcbuffer requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(AlwaysNeTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::EINTERSECTS_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 8, + "EintersectsTcbufferTcbuffer requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(EintersectsTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: EINTERSECTS_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::AINTERSECTS_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 8, + "AintersectsTcbufferTcbuffer requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(AintersectsTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: AINTERSECTS_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::ECOVERS_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 8, + "EcoversTcbufferTcbuffer requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(EcoversTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: ECOVERS_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::ACOVERS_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 8, + "AcoversTcbufferTcbuffer requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(AcoversTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: ACOVERS_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::ADISJOINT_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 8, + "AdisjointTcbufferTcbuffer requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(AdisjointTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: ADISJOINT_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::ETOUCHES_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 8, + "EtouchesTcbufferTcbuffer requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(EtouchesTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: ETOUCHES_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::ATOUCHES_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 8, + "AtouchesTcbufferTcbuffer requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(AtouchesTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: ATOUCHES_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::NAD_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 8, + "NadTcbufferTcbuffer requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(NadTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: NAD_TCBUFFER_TCBUFFER */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 8b8a2f17215ed54b33c259587521876419ef4b75 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 07:15:32 +0200 Subject: [PATCH 65/86] feat(meos): add tcbuffer_tcbuffer dwithin and mindistance NES operators (W117) Wires three tcbuffer-vs-tcbuffer operators that take a distance threshold using a 9-arg all-numeric pattern (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64, dist:FLOAT64) -> FLOAT64. Operators: EDWITHIN_TCBUFFER_TCBUFFER, ADWITHIN_TCBUFFER_TCBUFFER (return 0/1), and MINDISTANCE_TCBUFFER_TCBUFFER (returns the minimum distance or -1.0 on error). --- ...dwithinTcbufferTcbufferLogicalFunction.hpp | 55 ++++++++ ...dwithinTcbufferTcbufferLogicalFunction.hpp | 55 ++++++++ ...istanceTcbufferTcbufferLogicalFunction.hpp | 55 ++++++++ ...dwithinTcbufferTcbufferLogicalFunction.cpp | 122 ++++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + ...dwithinTcbufferTcbufferLogicalFunction.cpp | 122 ++++++++++++++++++ ...istanceTcbufferTcbufferLogicalFunction.cpp | 122 ++++++++++++++++++ ...withinTcbufferTcbufferPhysicalFunction.hpp | 37 ++++++ ...withinTcbufferTcbufferPhysicalFunction.hpp | 37 ++++++ ...stanceTcbufferTcbufferPhysicalFunction.hpp | 37 ++++++ ...withinTcbufferTcbufferPhysicalFunction.cpp | 117 +++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + ...withinTcbufferTcbufferPhysicalFunction.cpp | 117 +++++++++++++++++ ...stanceTcbufferTcbufferPhysicalFunction.cpp | 117 +++++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 5 +- .../src/AntlrSQLQueryPlanCreator.cpp | 51 ++++++++ 16 files changed, 1054 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AdwithinTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EdwithinTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/MindistanceTcbufferTcbufferLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AdwithinTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EdwithinTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/MindistanceTcbufferTcbufferLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AdwithinTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EdwithinTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/MindistanceTcbufferTcbufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AdwithinTcbufferTcbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EdwithinTcbufferTcbufferPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/MindistanceTcbufferTcbufferPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AdwithinTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AdwithinTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..b67ce5cfad --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AdwithinTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tcbuffer instants are always within the given distance, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64, + * dist:FLOAT64) -> FLOAT64. + */ +class AdwithinTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AdwithinTcbufferTcbuffer"; + + AdwithinTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2, LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EdwithinTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EdwithinTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..a67c2c1b1b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EdwithinTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tcbuffer instants are ever within the given distance, 0.0 otherwise. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64, + * dist:FLOAT64) -> FLOAT64. + */ +class EdwithinTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EdwithinTcbufferTcbuffer"; + + EdwithinTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2, LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/MindistanceTcbufferTcbufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/MindistanceTcbufferTcbufferLogicalFunction.hpp new file mode 100644 index 0000000000..b473b8a36c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/MindistanceTcbufferTcbufferLogicalFunction.hpp @@ -0,0 +1,55 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the minimum distance between two tcbuffer instants within the given threshold. + * + * Args: (lon1:FLOAT64, lat1:FLOAT64, r1:FLOAT64, ts1:UINT64, + * lon2:FLOAT64, lat2:FLOAT64, r2:FLOAT64, ts2:UINT64, + * dist:FLOAT64) -> FLOAT64. + */ +class MindistanceTcbufferTcbufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "MindistanceTcbufferTcbuffer"; + + MindistanceTcbufferTcbufferLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, + LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, + LogicalFunction ts2, LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AdwithinTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AdwithinTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..e32b576ff6 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AdwithinTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,122 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AdwithinTcbufferTcbufferLogicalFunction::AdwithinTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2, + LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(9); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); + parameters.push_back(std::move(dist)); +} + +DataType AdwithinTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AdwithinTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AdwithinTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AdwithinTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 9, + "AdwithinTcbufferTcbufferLogicalFunction requires 9 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AdwithinTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool AdwithinTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AdwithinTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AdwithinTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(9); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + INVARIANT(c[8].getDataType().isType(DataType::Type::FLOAT64), "dist must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AdwithinTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAdwithinTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 9, + "AdwithinTcbufferTcbufferLogicalFunction requires 9 children but got {}", + arguments.children.size()); + return AdwithinTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7]), + std::move(arguments.children[8])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 6ec03bb757..d0859d5ddd 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -377,6 +377,9 @@ add_plugin(AdisjointTcbufferTcbuffer LogicalFunction nes-logical-operators Adisj add_plugin(EtouchesTcbufferTcbuffer LogicalFunction nes-logical-operators EtouchesTcbufferTcbufferLogicalFunction.cpp) add_plugin(AtouchesTcbufferTcbuffer LogicalFunction nes-logical-operators AtouchesTcbufferTcbufferLogicalFunction.cpp) add_plugin(NadTcbufferTcbuffer LogicalFunction nes-logical-operators NadTcbufferTcbufferLogicalFunction.cpp) +add_plugin(EdwithinTcbufferTcbuffer LogicalFunction nes-logical-operators EdwithinTcbufferTcbufferLogicalFunction.cpp) +add_plugin(AdwithinTcbufferTcbuffer LogicalFunction nes-logical-operators AdwithinTcbufferTcbufferLogicalFunction.cpp) +add_plugin(MindistanceTcbufferTcbuffer LogicalFunction nes-logical-operators MindistanceTcbufferTcbufferLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EdwithinTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EdwithinTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..ec7a29673a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EdwithinTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,122 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EdwithinTcbufferTcbufferLogicalFunction::EdwithinTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2, + LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(9); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); + parameters.push_back(std::move(dist)); +} + +DataType EdwithinTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EdwithinTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EdwithinTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EdwithinTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 9, + "EdwithinTcbufferTcbufferLogicalFunction requires 9 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EdwithinTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool EdwithinTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EdwithinTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EdwithinTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(9); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + INVARIANT(c[8].getDataType().isType(DataType::Type::FLOAT64), "dist must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EdwithinTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEdwithinTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 9, + "EdwithinTcbufferTcbufferLogicalFunction requires 9 children but got {}", + arguments.children.size()); + return EdwithinTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7]), + std::move(arguments.children[8])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/MindistanceTcbufferTcbufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/MindistanceTcbufferTcbufferLogicalFunction.cpp new file mode 100644 index 0000000000..280265eb0f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/MindistanceTcbufferTcbufferLogicalFunction.cpp @@ -0,0 +1,122 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +MindistanceTcbufferTcbufferLogicalFunction::MindistanceTcbufferTcbufferLogicalFunction( + LogicalFunction lon1, LogicalFunction lat1, LogicalFunction r1, LogicalFunction ts1, + LogicalFunction lon2, LogicalFunction lat2, LogicalFunction r2, LogicalFunction ts2, + LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(9); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(r1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(r2)); + parameters.push_back(std::move(ts2)); + parameters.push_back(std::move(dist)); +} + +DataType MindistanceTcbufferTcbufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction MindistanceTcbufferTcbufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector MindistanceTcbufferTcbufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction MindistanceTcbufferTcbufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 9, + "MindistanceTcbufferTcbufferLogicalFunction requires 9 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view MindistanceTcbufferTcbufferLogicalFunction::getType() const { return NAME; } + +bool MindistanceTcbufferTcbufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string MindistanceTcbufferTcbufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction MindistanceTcbufferTcbufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(9); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "r1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "r2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + INVARIANT(c[8].getDataType().isType(DataType::Type::FLOAT64), "dist must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction MindistanceTcbufferTcbufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterMindistanceTcbufferTcbufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 9, + "MindistanceTcbufferTcbufferLogicalFunction requires 9 children but got {}", + arguments.children.size()); + return MindistanceTcbufferTcbufferLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7]), + std::move(arguments.children[8])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AdwithinTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AdwithinTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..1c4700ae3f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AdwithinTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AdwithinTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + AdwithinTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2, PhysicalFunction dist); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EdwithinTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EdwithinTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..4ff9cac817 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EdwithinTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EdwithinTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + EdwithinTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2, PhysicalFunction dist); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/MindistanceTcbufferTcbufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/MindistanceTcbufferTcbufferPhysicalFunction.hpp new file mode 100644 index 0000000000..1bbffb3bb6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/MindistanceTcbufferTcbufferPhysicalFunction.hpp @@ -0,0 +1,37 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class MindistanceTcbufferTcbufferPhysicalFunction : public PhysicalFunctionConcept { +public: + MindistanceTcbufferTcbufferPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, + PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, + PhysicalFunction ts2, PhysicalFunction dist); + + VarVal execute(const Record& record, ArenaRef& arena) const override; + +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AdwithinTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AdwithinTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..36a331f03f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AdwithinTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AdwithinTcbufferTcbufferPhysicalFunction::AdwithinTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2, + PhysicalFunction dist) +{ + paramFns.reserve(9); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); + paramFns.push_back(std::move(dist)); +} + +VarVal AdwithinTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + auto dist = paramFns[8].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2, + double dist) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + int r = adwithin_tcbuffer_tcbuffer(tcb1, tcb2, dist); + free(tcb1); free(tcb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2, dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAdwithinTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 9, + "AdwithinTcbufferTcbufferPhysicalFunction requires 9 children but got {}", + arguments.childFunctions.size()); + return AdwithinTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7]), + std::move(arguments.childFunctions[8])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 9873b4aa00..7476871093 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -376,6 +376,9 @@ add_plugin(AdisjointTcbufferTcbuffer PhysicalFunction nes-physical-operators Adi add_plugin(EtouchesTcbufferTcbuffer PhysicalFunction nes-physical-operators EtouchesTcbufferTcbufferPhysicalFunction.cpp) add_plugin(AtouchesTcbufferTcbuffer PhysicalFunction nes-physical-operators AtouchesTcbufferTcbufferPhysicalFunction.cpp) add_plugin(NadTcbufferTcbuffer PhysicalFunction nes-physical-operators NadTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(EdwithinTcbufferTcbuffer PhysicalFunction nes-physical-operators EdwithinTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(AdwithinTcbufferTcbuffer PhysicalFunction nes-physical-operators AdwithinTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(MindistanceTcbufferTcbuffer PhysicalFunction nes-physical-operators MindistanceTcbufferTcbufferPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EdwithinTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EdwithinTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..0516c6be91 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EdwithinTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EdwithinTcbufferTcbufferPhysicalFunction::EdwithinTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2, + PhysicalFunction dist) +{ + paramFns.reserve(9); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); + paramFns.push_back(std::move(dist)); +} + +VarVal EdwithinTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + auto dist = paramFns[8].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2, + double dist) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + int r = edwithin_tcbuffer_tcbuffer(tcb1, tcb2, dist); + free(tcb1); free(tcb2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2, dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEdwithinTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 9, + "EdwithinTcbufferTcbufferPhysicalFunction requires 9 children but got {}", + arguments.childFunctions.size()); + return EdwithinTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7]), + std::move(arguments.childFunctions[8])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/MindistanceTcbufferTcbufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/MindistanceTcbufferTcbufferPhysicalFunction.cpp new file mode 100644 index 0000000000..07e5591857 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/MindistanceTcbufferTcbufferPhysicalFunction.cpp @@ -0,0 +1,117 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +MindistanceTcbufferTcbufferPhysicalFunction::MindistanceTcbufferTcbufferPhysicalFunction( + PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction r1, PhysicalFunction ts1, + PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction r2, PhysicalFunction ts2, + PhysicalFunction dist) +{ + paramFns.reserve(9); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(r1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(r2)); + paramFns.push_back(std::move(ts2)); + paramFns.push_back(std::move(dist)); +} + +VarVal MindistanceTcbufferTcbufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto r1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto lon2 = paramFns[4].execute(record, arena).cast(); + auto lat2 = paramFns[5].execute(record, arena).cast(); + auto r2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + auto dist = paramFns[8].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double lon1, double lat1, double r1, uint64_t ts1, + double lon2, double lat2, double r2, uint64_t ts2, + double dist) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string pt1 = fmt::format("POINT({} {})", lon1, lat1); + GSERIALIZED* gs1 = geom_in(pt1.c_str(), -1); + if (!gs1) return 0.0; + Cbuffer* cb1 = cbuffer_make(gs1, r1); + free(gs1); + if (!cb1) return 0.0; + Temporal* tcb1 = (Temporal*)tcbufferinst_make(cb1, (TimestampTz)ts1); + free(cb1); + if (!tcb1) return 0.0; + std::string pt2 = fmt::format("POINT({} {})", lon2, lat2); + GSERIALIZED* gs2 = geom_in(pt2.c_str(), -1); + if (!gs2) { free(tcb1); return 0.0; } + Cbuffer* cb2 = cbuffer_make(gs2, r2); + free(gs2); + if (!cb2) { free(tcb1); return 0.0; } + Temporal* tcb2 = (Temporal*)tcbufferinst_make(cb2, (TimestampTz)ts2); + free(cb2); + if (!tcb2) { free(tcb1); return 0.0; } + double r = mindistance_tcbuffer_tcbuffer(tcb1, tcb2, dist); + free(tcb1); free(tcb2); + return r; + } catch (const std::exception&) { return -1.0; } + }, + lon1, lat1, r1, ts1, lon2, lat2, r2, ts2, dist); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterMindistanceTcbufferTcbufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 9, + "MindistanceTcbufferTcbufferPhysicalFunction requires 9 children but got {}", + arguments.childFunctions.size()); + return MindistanceTcbufferTcbufferPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7]), + std::move(arguments.childFunctions[8])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 57092f5857..5bbf4a6792 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -847,6 +847,9 @@ ADISJOINT_TCBUFFER_TCBUFFER: 'ADISJOINT_TCBUFFER_TCBUFFER' | 'adisjoint_tcbuffer ETOUCHES_TCBUFFER_TCBUFFER: 'ETOUCHES_TCBUFFER_TCBUFFER' | 'etouches_tcbuffer_tcbuffer'; ATOUCHES_TCBUFFER_TCBUFFER: 'ATOUCHES_TCBUFFER_TCBUFFER' | 'atouches_tcbuffer_tcbuffer'; NAD_TCBUFFER_TCBUFFER: 'NAD_TCBUFFER_TCBUFFER' | 'nad_tcbuffer_tcbuffer'; +EDWITHIN_TCBUFFER_TCBUFFER: 'EDWITHIN_TCBUFFER_TCBUFFER' | 'edwithin_tcbuffer_tcbuffer'; +ADWITHIN_TCBUFFER_TCBUFFER: 'ADWITHIN_TCBUFFER_TCBUFFER' | 'adwithin_tcbuffer_tcbuffer'; +MINDISTANCE_TCBUFFER_TCBUFFER: 'MINDISTANCE_TCBUFFER_TCBUFFER' | 'mindistance_tcbuffer_tcbuffer'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 754015f335..99130e443e 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -428,6 +428,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -9882,6 +9885,54 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(NadTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); } /* END CODEGEN PARSER GLUE: NAD_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::EDWITHIN_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 9, + "EdwithinTcbufferTcbuffer requires 9 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + auto arg8 = visit(ctx->functionParam(8)).as(); + return LogicalFunction(EdwithinTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8))); + } + /* END CODEGEN PARSER GLUE: EDWITHIN_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::ADWITHIN_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 9, + "AdwithinTcbufferTcbuffer requires 9 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + auto arg8 = visit(ctx->functionParam(8)).as(); + return LogicalFunction(AdwithinTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8))); + } + /* END CODEGEN PARSER GLUE: ADWITHIN_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::MINDISTANCE_TCBUFFER_TCBUFFER: { + PRECONDITION(ctx->functionParam().size() == 9, + "MindistanceTcbufferTcbuffer requires 9 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + auto arg8 = visit(ctx->functionParam(8)).as(); + return LogicalFunction(MindistanceTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8))); + } + /* END CODEGEN PARSER GLUE: MINDISTANCE_TCBUFFER_TCBUFFER */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 7835fa8d9d1b9c593ef6027fa59bcc165dc3f2b0 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 08:08:13 +0200 Subject: [PATCH 66/86] feat(meos): add tnpoint per-event scalar operators for geo and npoint (W118) Wires ten tnpoint operators using three new patterns. A tnpoint instant is represented as (rid:UINT64, pos:FLOAT64, ts:UINT64) and built via npoint_make then tnpointinst_make. Pattern A (4-arg with VARCHAR): NAD_TNPOINT_GEO. Pattern B (5-arg tnpoint-first: rid1,pos1,ts,rid2,pos2): EVER_EQ/ALWAYS_EQ/ EVER_NE/ALWAYS_NE/NAD _TNPOINT_NPOINT. Pattern C (5-arg npoint-first reversed: rid_np,pos_np,rid_tp,pos_tp,ts): EVER_EQ/ALWAYS_EQ/EVER_NE/ALWAYS_NE _NPOINT_TNPOINT. --- .../AlwaysEqNpointTnpointLogicalFunction.hpp | 48 +++++++ .../AlwaysEqTnpointNpointLogicalFunction.hpp | 48 +++++++ .../AlwaysNeNpointTnpointLogicalFunction.hpp | 48 +++++++ .../AlwaysNeTnpointNpointLogicalFunction.hpp | 48 +++++++ .../EverEqNpointTnpointLogicalFunction.hpp | 48 +++++++ .../EverEqTnpointNpointLogicalFunction.hpp | 48 +++++++ .../EverNeNpointTnpointLogicalFunction.hpp | 48 +++++++ .../EverNeTnpointNpointLogicalFunction.hpp | 48 +++++++ .../Meos/NadTnpointGeoLogicalFunction.hpp | 48 +++++++ .../Meos/NadTnpointNpointLogicalFunction.hpp | 48 +++++++ .../AlwaysEqNpointTnpointLogicalFunction.cpp | 108 +++++++++++++++ .../AlwaysEqTnpointNpointLogicalFunction.cpp | 108 +++++++++++++++ .../AlwaysNeNpointTnpointLogicalFunction.cpp | 108 +++++++++++++++ .../AlwaysNeTnpointNpointLogicalFunction.cpp | 108 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 10 ++ .../EverEqNpointTnpointLogicalFunction.cpp | 108 +++++++++++++++ .../EverEqTnpointNpointLogicalFunction.cpp | 108 +++++++++++++++ .../EverNeNpointTnpointLogicalFunction.cpp | 108 +++++++++++++++ .../EverNeTnpointNpointLogicalFunction.cpp | 108 +++++++++++++++ .../Meos/NadTnpointGeoLogicalFunction.cpp | 105 ++++++++++++++ .../Meos/NadTnpointNpointLogicalFunction.cpp | 108 +++++++++++++++ .../AlwaysEqNpointTnpointPhysicalFunction.hpp | 32 +++++ .../AlwaysEqTnpointNpointPhysicalFunction.hpp | 32 +++++ .../AlwaysNeNpointTnpointPhysicalFunction.hpp | 32 +++++ .../AlwaysNeTnpointNpointPhysicalFunction.hpp | 32 +++++ .../EverEqNpointTnpointPhysicalFunction.hpp | 32 +++++ .../EverEqTnpointNpointPhysicalFunction.hpp | 32 +++++ .../EverNeNpointTnpointPhysicalFunction.hpp | 32 +++++ .../EverNeTnpointNpointPhysicalFunction.hpp | 32 +++++ .../Meos/NadTnpointGeoPhysicalFunction.hpp | 32 +++++ .../Meos/NadTnpointNpointPhysicalFunction.hpp | 32 +++++ .../AlwaysEqNpointTnpointPhysicalFunction.cpp | 88 ++++++++++++ .../AlwaysEqTnpointNpointPhysicalFunction.cpp | 88 ++++++++++++ .../AlwaysNeNpointTnpointPhysicalFunction.cpp | 88 ++++++++++++ .../AlwaysNeTnpointNpointPhysicalFunction.cpp | 88 ++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 10 ++ .../EverEqNpointTnpointPhysicalFunction.cpp | 88 ++++++++++++ .../EverEqTnpointNpointPhysicalFunction.cpp | 88 ++++++++++++ .../EverNeNpointTnpointPhysicalFunction.cpp | 88 ++++++++++++ .../EverNeTnpointNpointPhysicalFunction.cpp | 88 ++++++++++++ .../Meos/NadTnpointGeoPhysicalFunction.cpp | 89 ++++++++++++ .../Meos/NadTnpointNpointPhysicalFunction.cpp | 88 ++++++++++++ nes-sql-parser/AntlrSQL.g4 | 12 +- .../src/AntlrSQLQueryPlanCreator.cpp | 129 ++++++++++++++++++ 44 files changed, 2918 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqNpointTnpointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTnpointNpointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeNpointTnpointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTnpointNpointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqNpointTnpointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTnpointNpointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeNpointTnpointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTnpointNpointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/NadTnpointGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/NadTnpointNpointLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqNpointTnpointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTnpointNpointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeNpointTnpointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTnpointNpointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqNpointTnpointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTnpointNpointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeNpointTnpointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTnpointNpointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/NadTnpointGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/NadTnpointNpointLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqNpointTnpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTnpointNpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeNpointTnpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTnpointNpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqNpointTnpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTnpointNpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeNpointTnpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTnpointNpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/NadTnpointGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/NadTnpointNpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqNpointTnpointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTnpointNpointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeNpointTnpointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTnpointNpointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqNpointTnpointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTnpointNpointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeNpointTnpointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTnpointNpointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/NadTnpointGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/NadTnpointNpointPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqNpointTnpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqNpointTnpointLogicalFunction.hpp new file mode 100644 index 0000000000..0cf7786548 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqNpointTnpointLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the static npoint is always equal to the tnpoint instant, 0.0 otherwise. + */ +class AlwaysEqNpointTnpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqNpointTnpoint"; + + AlwaysEqNpointTnpointLogicalFunction(LogicalFunction rid_np, LogicalFunction pos_np, LogicalFunction rid_tp, LogicalFunction pos_tp, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTnpointNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTnpointNpointLogicalFunction.hpp new file mode 100644 index 0000000000..72f359cb5c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTnpointNpointLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tnpoint instant is always equal to the static npoint, 0.0 otherwise. + */ +class AlwaysEqTnpointNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTnpointNpoint"; + + AlwaysEqTnpointNpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts, LogicalFunction rid2, LogicalFunction pos2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeNpointTnpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeNpointTnpointLogicalFunction.hpp new file mode 100644 index 0000000000..adabbaa11e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeNpointTnpointLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the static npoint is always not equal to the tnpoint instant, 0.0 otherwise. + */ +class AlwaysNeNpointTnpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeNpointTnpoint"; + + AlwaysNeNpointTnpointLogicalFunction(LogicalFunction rid_np, LogicalFunction pos_np, LogicalFunction rid_tp, LogicalFunction pos_tp, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTnpointNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTnpointNpointLogicalFunction.hpp new file mode 100644 index 0000000000..4ba4d57134 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTnpointNpointLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tnpoint instant is always not equal to the static npoint, 0.0 otherwise. + */ +class AlwaysNeTnpointNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTnpointNpoint"; + + AlwaysNeTnpointNpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts, LogicalFunction rid2, LogicalFunction pos2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqNpointTnpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqNpointTnpointLogicalFunction.hpp new file mode 100644 index 0000000000..29ec840797 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqNpointTnpointLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the static npoint is ever equal to the tnpoint instant, 0.0 otherwise. + */ +class EverEqNpointTnpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqNpointTnpoint"; + + EverEqNpointTnpointLogicalFunction(LogicalFunction rid_np, LogicalFunction pos_np, LogicalFunction rid_tp, LogicalFunction pos_tp, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTnpointNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTnpointNpointLogicalFunction.hpp new file mode 100644 index 0000000000..527e8a0d49 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTnpointNpointLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tnpoint instant is ever equal to the static npoint, 0.0 otherwise. + */ +class EverEqTnpointNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTnpointNpoint"; + + EverEqTnpointNpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts, LogicalFunction rid2, LogicalFunction pos2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeNpointTnpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeNpointTnpointLogicalFunction.hpp new file mode 100644 index 0000000000..c03338e09b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeNpointTnpointLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the static npoint is ever not equal to the tnpoint instant, 0.0 otherwise. + */ +class EverNeNpointTnpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeNpointTnpoint"; + + EverNeNpointTnpointLogicalFunction(LogicalFunction rid_np, LogicalFunction pos_np, LogicalFunction rid_tp, LogicalFunction pos_tp, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTnpointNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTnpointNpointLogicalFunction.hpp new file mode 100644 index 0000000000..83ab3b2a26 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTnpointNpointLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tnpoint instant is ever not equal to the static npoint, 0.0 otherwise. + */ +class EverNeTnpointNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTnpointNpoint"; + + EverNeTnpointNpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts, LogicalFunction rid2, LogicalFunction pos2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/NadTnpointGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/NadTnpointGeoLogicalFunction.hpp new file mode 100644 index 0000000000..2860d4f91a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/NadTnpointGeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nearest approach distance between a tnpoint instant and a static geometry. + */ +class NadTnpointGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "NadTnpointGeo"; + + NadTnpointGeoLogicalFunction(LogicalFunction rid, LogicalFunction pos, LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/NadTnpointNpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/NadTnpointNpointLogicalFunction.hpp new file mode 100644 index 0000000000..90f67e08f6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/NadTnpointNpointLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nearest approach distance between a tnpoint instant and a static npoint. + */ +class NadTnpointNpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "NadTnpointNpoint"; + + NadTnpointNpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts, LogicalFunction rid2, LogicalFunction pos2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqNpointTnpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqNpointTnpointLogicalFunction.cpp new file mode 100644 index 0000000000..0627232d65 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqNpointTnpointLogicalFunction.cpp @@ -0,0 +1,108 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqNpointTnpointLogicalFunction::AlwaysEqNpointTnpointLogicalFunction(LogicalFunction rid_np, LogicalFunction pos_np, LogicalFunction rid_tp, LogicalFunction pos_tp, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(rid_np)); + parameters.push_back(std::move(pos_np)); + parameters.push_back(std::move(rid_tp)); + parameters.push_back(std::move(pos_tp)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqNpointTnpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqNpointTnpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqNpointTnpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqNpointTnpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "AlwaysEqNpointTnpointLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqNpointTnpointLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqNpointTnpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqNpointTnpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqNpointTnpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid_np must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos_np must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "rid_tp must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "pos_tp must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysEqNpointTnpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqNpointTnpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "AlwaysEqNpointTnpointLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return AlwaysEqNpointTnpointLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTnpointNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTnpointNpointLogicalFunction.cpp new file mode 100644 index 0000000000..1c1e2071b7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTnpointNpointLogicalFunction.cpp @@ -0,0 +1,108 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTnpointNpointLogicalFunction::AlwaysEqTnpointNpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts, LogicalFunction rid2, LogicalFunction pos2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(rid1)); + parameters.push_back(std::move(pos1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(rid2)); + parameters.push_back(std::move(pos2)); +} + +DataType AlwaysEqTnpointNpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTnpointNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTnpointNpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTnpointNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "AlwaysEqTnpointNpointLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTnpointNpointLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTnpointNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTnpointNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqTnpointNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid1 must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "rid2 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "pos2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AlwaysEqTnpointNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTnpointNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "AlwaysEqTnpointNpointLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return AlwaysEqTnpointNpointLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeNpointTnpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeNpointTnpointLogicalFunction.cpp new file mode 100644 index 0000000000..bc216bc4b0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeNpointTnpointLogicalFunction.cpp @@ -0,0 +1,108 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeNpointTnpointLogicalFunction::AlwaysNeNpointTnpointLogicalFunction(LogicalFunction rid_np, LogicalFunction pos_np, LogicalFunction rid_tp, LogicalFunction pos_tp, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(rid_np)); + parameters.push_back(std::move(pos_np)); + parameters.push_back(std::move(rid_tp)); + parameters.push_back(std::move(pos_tp)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeNpointTnpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeNpointTnpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeNpointTnpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeNpointTnpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "AlwaysNeNpointTnpointLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeNpointTnpointLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeNpointTnpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeNpointTnpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeNpointTnpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid_np must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos_np must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "rid_tp must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "pos_tp must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysNeNpointTnpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeNpointTnpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "AlwaysNeNpointTnpointLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return AlwaysNeNpointTnpointLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTnpointNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTnpointNpointLogicalFunction.cpp new file mode 100644 index 0000000000..e6271da03e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTnpointNpointLogicalFunction.cpp @@ -0,0 +1,108 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTnpointNpointLogicalFunction::AlwaysNeTnpointNpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts, LogicalFunction rid2, LogicalFunction pos2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(rid1)); + parameters.push_back(std::move(pos1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(rid2)); + parameters.push_back(std::move(pos2)); +} + +DataType AlwaysNeTnpointNpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTnpointNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTnpointNpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTnpointNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "AlwaysNeTnpointNpointLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTnpointNpointLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTnpointNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTnpointNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeTnpointNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid1 must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "rid2 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "pos2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AlwaysNeTnpointNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTnpointNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "AlwaysNeTnpointNpointLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return AlwaysNeTnpointNpointLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index d0859d5ddd..76816ac322 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -380,6 +380,16 @@ add_plugin(NadTcbufferTcbuffer LogicalFunction nes-logical-operators NadTcbuffer add_plugin(EdwithinTcbufferTcbuffer LogicalFunction nes-logical-operators EdwithinTcbufferTcbufferLogicalFunction.cpp) add_plugin(AdwithinTcbufferTcbuffer LogicalFunction nes-logical-operators AdwithinTcbufferTcbufferLogicalFunction.cpp) add_plugin(MindistanceTcbufferTcbuffer LogicalFunction nes-logical-operators MindistanceTcbufferTcbufferLogicalFunction.cpp) +add_plugin(NadTnpointGeo LogicalFunction nes-logical-operators NadTnpointGeoLogicalFunction.cpp) +add_plugin(EverEqTnpointNpoint LogicalFunction nes-logical-operators EverEqTnpointNpointLogicalFunction.cpp) +add_plugin(AlwaysEqTnpointNpoint LogicalFunction nes-logical-operators AlwaysEqTnpointNpointLogicalFunction.cpp) +add_plugin(EverNeTnpointNpoint LogicalFunction nes-logical-operators EverNeTnpointNpointLogicalFunction.cpp) +add_plugin(AlwaysNeTnpointNpoint LogicalFunction nes-logical-operators AlwaysNeTnpointNpointLogicalFunction.cpp) +add_plugin(NadTnpointNpoint LogicalFunction nes-logical-operators NadTnpointNpointLogicalFunction.cpp) +add_plugin(EverEqNpointTnpoint LogicalFunction nes-logical-operators EverEqNpointTnpointLogicalFunction.cpp) +add_plugin(AlwaysEqNpointTnpoint LogicalFunction nes-logical-operators AlwaysEqNpointTnpointLogicalFunction.cpp) +add_plugin(EverNeNpointTnpoint LogicalFunction nes-logical-operators EverNeNpointTnpointLogicalFunction.cpp) +add_plugin(AlwaysNeNpointTnpoint LogicalFunction nes-logical-operators AlwaysNeNpointTnpointLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqNpointTnpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqNpointTnpointLogicalFunction.cpp new file mode 100644 index 0000000000..c7e8673ad2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqNpointTnpointLogicalFunction.cpp @@ -0,0 +1,108 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqNpointTnpointLogicalFunction::EverEqNpointTnpointLogicalFunction(LogicalFunction rid_np, LogicalFunction pos_np, LogicalFunction rid_tp, LogicalFunction pos_tp, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(rid_np)); + parameters.push_back(std::move(pos_np)); + parameters.push_back(std::move(rid_tp)); + parameters.push_back(std::move(pos_tp)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqNpointTnpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqNpointTnpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqNpointTnpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqNpointTnpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "EverEqNpointTnpointLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqNpointTnpointLogicalFunction::getType() const { return NAME; } + +bool EverEqNpointTnpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqNpointTnpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqNpointTnpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid_np must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos_np must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "rid_tp must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "pos_tp must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverEqNpointTnpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqNpointTnpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "EverEqNpointTnpointLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return EverEqNpointTnpointLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTnpointNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTnpointNpointLogicalFunction.cpp new file mode 100644 index 0000000000..f1a267f874 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTnpointNpointLogicalFunction.cpp @@ -0,0 +1,108 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTnpointNpointLogicalFunction::EverEqTnpointNpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts, LogicalFunction rid2, LogicalFunction pos2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(rid1)); + parameters.push_back(std::move(pos1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(rid2)); + parameters.push_back(std::move(pos2)); +} + +DataType EverEqTnpointNpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTnpointNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTnpointNpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTnpointNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "EverEqTnpointNpointLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTnpointNpointLogicalFunction::getType() const { return NAME; } + +bool EverEqTnpointNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTnpointNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqTnpointNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid1 must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "rid2 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "pos2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EverEqTnpointNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTnpointNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "EverEqTnpointNpointLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return EverEqTnpointNpointLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeNpointTnpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeNpointTnpointLogicalFunction.cpp new file mode 100644 index 0000000000..0a95391835 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeNpointTnpointLogicalFunction.cpp @@ -0,0 +1,108 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeNpointTnpointLogicalFunction::EverNeNpointTnpointLogicalFunction(LogicalFunction rid_np, LogicalFunction pos_np, LogicalFunction rid_tp, LogicalFunction pos_tp, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(rid_np)); + parameters.push_back(std::move(pos_np)); + parameters.push_back(std::move(rid_tp)); + parameters.push_back(std::move(pos_tp)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeNpointTnpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeNpointTnpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeNpointTnpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeNpointTnpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "EverNeNpointTnpointLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeNpointTnpointLogicalFunction::getType() const { return NAME; } + +bool EverNeNpointTnpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeNpointTnpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeNpointTnpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid_np must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos_np must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "rid_tp must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "pos_tp must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverNeNpointTnpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeNpointTnpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "EverNeNpointTnpointLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return EverNeNpointTnpointLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTnpointNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTnpointNpointLogicalFunction.cpp new file mode 100644 index 0000000000..9a47532426 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTnpointNpointLogicalFunction.cpp @@ -0,0 +1,108 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTnpointNpointLogicalFunction::EverNeTnpointNpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts, LogicalFunction rid2, LogicalFunction pos2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(rid1)); + parameters.push_back(std::move(pos1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(rid2)); + parameters.push_back(std::move(pos2)); +} + +DataType EverNeTnpointNpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTnpointNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTnpointNpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTnpointNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "EverNeTnpointNpointLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTnpointNpointLogicalFunction::getType() const { return NAME; } + +bool EverNeTnpointNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTnpointNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeTnpointNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid1 must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "rid2 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "pos2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EverNeTnpointNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTnpointNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "EverNeTnpointNpointLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return EverNeTnpointNpointLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/NadTnpointGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/NadTnpointGeoLogicalFunction.cpp new file mode 100644 index 0000000000..86e022e4a7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/NadTnpointGeoLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +NadTnpointGeoLogicalFunction::NadTnpointGeoLogicalFunction(LogicalFunction rid, LogicalFunction pos, LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(rid)); + parameters.push_back(std::move(pos)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType NadTnpointGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction NadTnpointGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector NadTnpointGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction NadTnpointGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "NadTnpointGeoLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view NadTnpointGeoLogicalFunction::getType() const { return NAME; } + +bool NadTnpointGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string NadTnpointGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction NadTnpointGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction NadTnpointGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterNadTnpointGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "NadTnpointGeoLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return NadTnpointGeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/NadTnpointNpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/NadTnpointNpointLogicalFunction.cpp new file mode 100644 index 0000000000..4b74567379 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/NadTnpointNpointLogicalFunction.cpp @@ -0,0 +1,108 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +NadTnpointNpointLogicalFunction::NadTnpointNpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts, LogicalFunction rid2, LogicalFunction pos2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(rid1)); + parameters.push_back(std::move(pos1)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(rid2)); + parameters.push_back(std::move(pos2)); +} + +DataType NadTnpointNpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction NadTnpointNpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector NadTnpointNpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction NadTnpointNpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "NadTnpointNpointLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view NadTnpointNpointLogicalFunction::getType() const { return NAME; } + +bool NadTnpointNpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string NadTnpointNpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction NadTnpointNpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid1 must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "rid2 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "pos2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction NadTnpointNpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterNadTnpointNpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "NadTnpointNpointLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return NadTnpointNpointLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqNpointTnpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqNpointTnpointPhysicalFunction.hpp new file mode 100644 index 0000000000..cba9924d21 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqNpointTnpointPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqNpointTnpointPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqNpointTnpointPhysicalFunction(PhysicalFunction rid_np, PhysicalFunction pos_np, PhysicalFunction rid_tp, PhysicalFunction pos_tp, PhysicalFunction ts); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTnpointNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTnpointNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..b430b92485 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTnpointNpointPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTnpointNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTnpointNpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts, PhysicalFunction rid2, PhysicalFunction pos2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeNpointTnpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeNpointTnpointPhysicalFunction.hpp new file mode 100644 index 0000000000..451ff1f286 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeNpointTnpointPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeNpointTnpointPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeNpointTnpointPhysicalFunction(PhysicalFunction rid_np, PhysicalFunction pos_np, PhysicalFunction rid_tp, PhysicalFunction pos_tp, PhysicalFunction ts); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTnpointNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTnpointNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..e2e017c3af --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTnpointNpointPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTnpointNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTnpointNpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts, PhysicalFunction rid2, PhysicalFunction pos2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqNpointTnpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqNpointTnpointPhysicalFunction.hpp new file mode 100644 index 0000000000..0f2fcb08ac --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqNpointTnpointPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqNpointTnpointPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqNpointTnpointPhysicalFunction(PhysicalFunction rid_np, PhysicalFunction pos_np, PhysicalFunction rid_tp, PhysicalFunction pos_tp, PhysicalFunction ts); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTnpointNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTnpointNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..43751866cc --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTnpointNpointPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTnpointNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTnpointNpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts, PhysicalFunction rid2, PhysicalFunction pos2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeNpointTnpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeNpointTnpointPhysicalFunction.hpp new file mode 100644 index 0000000000..98789d427d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeNpointTnpointPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeNpointTnpointPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeNpointTnpointPhysicalFunction(PhysicalFunction rid_np, PhysicalFunction pos_np, PhysicalFunction rid_tp, PhysicalFunction pos_tp, PhysicalFunction ts); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTnpointNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTnpointNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..52802bbd8b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTnpointNpointPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTnpointNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTnpointNpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts, PhysicalFunction rid2, PhysicalFunction pos2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/NadTnpointGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/NadTnpointGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..1d927ba586 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/NadTnpointGeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class NadTnpointGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + NadTnpointGeoPhysicalFunction(PhysicalFunction rid, PhysicalFunction pos, PhysicalFunction ts, PhysicalFunction wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/NadTnpointNpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/NadTnpointNpointPhysicalFunction.hpp new file mode 100644 index 0000000000..989d1c2707 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/NadTnpointNpointPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class NadTnpointNpointPhysicalFunction : public PhysicalFunctionConcept { +public: + NadTnpointNpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts, PhysicalFunction rid2, PhysicalFunction pos2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqNpointTnpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqNpointTnpointPhysicalFunction.cpp new file mode 100644 index 0000000000..fc8c94d546 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqNpointTnpointPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AlwaysEqNpointTnpointPhysicalFunction::AlwaysEqNpointTnpointPhysicalFunction(PhysicalFunction rid_np, PhysicalFunction pos_np, PhysicalFunction rid_tp, PhysicalFunction pos_tp, PhysicalFunction ts) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(rid_np)); + paramFns.push_back(std::move(pos_np)); + paramFns.push_back(std::move(rid_tp)); + paramFns.push_back(std::move(pos_tp)); + paramFns.push_back(std::move(ts)); +} + +VarVal AlwaysEqNpointTnpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid_np = paramFns[0].execute(record, arena).cast(); + auto pos_np = paramFns[1].execute(record, arena).cast(); + auto rid_tp = paramFns[2].execute(record, arena).cast(); + auto pos_tp = paramFns[3].execute(record, arena).cast(); + auto ts = paramFns[4].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t rid_np, double pos_np, uint64_t rid_tp, double pos_tp, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np_s = npoint_make((int64_t)rid_np, pos_np); + if (!np_s) return 0.0; + Npoint* np_t = npoint_make((int64_t)rid_tp, pos_tp); + if (!np_t) { free(np_s); return 0.0; } + Temporal* inst = (Temporal*)tnpointinst_make(np_t, (TimestampTz)ts); + free(np_t); + if (!inst) { free(np_s); return 0.0; } + int r = always_eq_npoint_tnpoint(np_s, inst); + free(np_s); free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + rid_np, pos_np, rid_tp, pos_tp, ts); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqNpointTnpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "AlwaysEqNpointTnpointPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqNpointTnpointPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTnpointNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTnpointNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..41a5538a86 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTnpointNpointPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AlwaysEqTnpointNpointPhysicalFunction::AlwaysEqTnpointNpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts, PhysicalFunction rid2, PhysicalFunction pos2) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(rid1)); + paramFns.push_back(std::move(pos1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(rid2)); + paramFns.push_back(std::move(pos2)); +} + +VarVal AlwaysEqTnpointNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid1 = paramFns[0].execute(record, arena).cast(); + auto pos1 = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto rid2 = paramFns[3].execute(record, arena).cast(); + auto pos2 = paramFns[4].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t rid1, double pos1, uint64_t ts, uint64_t rid2, double pos2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np1 = npoint_make((int64_t)rid1, pos1); + if (!np1) return 0.0; + Temporal* inst = (Temporal*)tnpointinst_make(np1, (TimestampTz)ts); + free(np1); + if (!inst) return 0.0; + Npoint* np2 = npoint_make((int64_t)rid2, pos2); + if (!np2) { free(inst); return 0.0; } + int r = always_eq_tnpoint_npoint(inst, np2); + free(inst); free(np2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + rid1, pos1, ts, rid2, pos2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTnpointNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "AlwaysEqTnpointNpointPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTnpointNpointPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeNpointTnpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeNpointTnpointPhysicalFunction.cpp new file mode 100644 index 0000000000..1dac3ef61b --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeNpointTnpointPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AlwaysNeNpointTnpointPhysicalFunction::AlwaysNeNpointTnpointPhysicalFunction(PhysicalFunction rid_np, PhysicalFunction pos_np, PhysicalFunction rid_tp, PhysicalFunction pos_tp, PhysicalFunction ts) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(rid_np)); + paramFns.push_back(std::move(pos_np)); + paramFns.push_back(std::move(rid_tp)); + paramFns.push_back(std::move(pos_tp)); + paramFns.push_back(std::move(ts)); +} + +VarVal AlwaysNeNpointTnpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid_np = paramFns[0].execute(record, arena).cast(); + auto pos_np = paramFns[1].execute(record, arena).cast(); + auto rid_tp = paramFns[2].execute(record, arena).cast(); + auto pos_tp = paramFns[3].execute(record, arena).cast(); + auto ts = paramFns[4].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t rid_np, double pos_np, uint64_t rid_tp, double pos_tp, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np_s = npoint_make((int64_t)rid_np, pos_np); + if (!np_s) return 0.0; + Npoint* np_t = npoint_make((int64_t)rid_tp, pos_tp); + if (!np_t) { free(np_s); return 0.0; } + Temporal* inst = (Temporal*)tnpointinst_make(np_t, (TimestampTz)ts); + free(np_t); + if (!inst) { free(np_s); return 0.0; } + int r = always_ne_npoint_tnpoint(np_s, inst); + free(np_s); free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + rid_np, pos_np, rid_tp, pos_tp, ts); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeNpointTnpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "AlwaysNeNpointTnpointPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeNpointTnpointPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTnpointNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTnpointNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..fde3d1240e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTnpointNpointPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AlwaysNeTnpointNpointPhysicalFunction::AlwaysNeTnpointNpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts, PhysicalFunction rid2, PhysicalFunction pos2) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(rid1)); + paramFns.push_back(std::move(pos1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(rid2)); + paramFns.push_back(std::move(pos2)); +} + +VarVal AlwaysNeTnpointNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid1 = paramFns[0].execute(record, arena).cast(); + auto pos1 = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto rid2 = paramFns[3].execute(record, arena).cast(); + auto pos2 = paramFns[4].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t rid1, double pos1, uint64_t ts, uint64_t rid2, double pos2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np1 = npoint_make((int64_t)rid1, pos1); + if (!np1) return 0.0; + Temporal* inst = (Temporal*)tnpointinst_make(np1, (TimestampTz)ts); + free(np1); + if (!inst) return 0.0; + Npoint* np2 = npoint_make((int64_t)rid2, pos2); + if (!np2) { free(inst); return 0.0; } + int r = always_ne_tnpoint_npoint(inst, np2); + free(inst); free(np2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + rid1, pos1, ts, rid2, pos2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTnpointNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "AlwaysNeTnpointNpointPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTnpointNpointPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 7476871093..9f072bfa7b 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -379,6 +379,16 @@ add_plugin(NadTcbufferTcbuffer PhysicalFunction nes-physical-operators NadTcbuff add_plugin(EdwithinTcbufferTcbuffer PhysicalFunction nes-physical-operators EdwithinTcbufferTcbufferPhysicalFunction.cpp) add_plugin(AdwithinTcbufferTcbuffer PhysicalFunction nes-physical-operators AdwithinTcbufferTcbufferPhysicalFunction.cpp) add_plugin(MindistanceTcbufferTcbuffer PhysicalFunction nes-physical-operators MindistanceTcbufferTcbufferPhysicalFunction.cpp) +add_plugin(NadTnpointGeo PhysicalFunction nes-physical-operators NadTnpointGeoPhysicalFunction.cpp) +add_plugin(EverEqTnpointNpoint PhysicalFunction nes-physical-operators EverEqTnpointNpointPhysicalFunction.cpp) +add_plugin(AlwaysEqTnpointNpoint PhysicalFunction nes-physical-operators AlwaysEqTnpointNpointPhysicalFunction.cpp) +add_plugin(EverNeTnpointNpoint PhysicalFunction nes-physical-operators EverNeTnpointNpointPhysicalFunction.cpp) +add_plugin(AlwaysNeTnpointNpoint PhysicalFunction nes-physical-operators AlwaysNeTnpointNpointPhysicalFunction.cpp) +add_plugin(NadTnpointNpoint PhysicalFunction nes-physical-operators NadTnpointNpointPhysicalFunction.cpp) +add_plugin(EverEqNpointTnpoint PhysicalFunction nes-physical-operators EverEqNpointTnpointPhysicalFunction.cpp) +add_plugin(AlwaysEqNpointTnpoint PhysicalFunction nes-physical-operators AlwaysEqNpointTnpointPhysicalFunction.cpp) +add_plugin(EverNeNpointTnpoint PhysicalFunction nes-physical-operators EverNeNpointTnpointPhysicalFunction.cpp) +add_plugin(AlwaysNeNpointTnpoint PhysicalFunction nes-physical-operators AlwaysNeNpointTnpointPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EverEqNpointTnpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqNpointTnpointPhysicalFunction.cpp new file mode 100644 index 0000000000..172d4caa24 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqNpointTnpointPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EverEqNpointTnpointPhysicalFunction::EverEqNpointTnpointPhysicalFunction(PhysicalFunction rid_np, PhysicalFunction pos_np, PhysicalFunction rid_tp, PhysicalFunction pos_tp, PhysicalFunction ts) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(rid_np)); + paramFns.push_back(std::move(pos_np)); + paramFns.push_back(std::move(rid_tp)); + paramFns.push_back(std::move(pos_tp)); + paramFns.push_back(std::move(ts)); +} + +VarVal EverEqNpointTnpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid_np = paramFns[0].execute(record, arena).cast(); + auto pos_np = paramFns[1].execute(record, arena).cast(); + auto rid_tp = paramFns[2].execute(record, arena).cast(); + auto pos_tp = paramFns[3].execute(record, arena).cast(); + auto ts = paramFns[4].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t rid_np, double pos_np, uint64_t rid_tp, double pos_tp, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np_s = npoint_make((int64_t)rid_np, pos_np); + if (!np_s) return 0.0; + Npoint* np_t = npoint_make((int64_t)rid_tp, pos_tp); + if (!np_t) { free(np_s); return 0.0; } + Temporal* inst = (Temporal*)tnpointinst_make(np_t, (TimestampTz)ts); + free(np_t); + if (!inst) { free(np_s); return 0.0; } + int r = ever_eq_npoint_tnpoint(np_s, inst); + free(np_s); free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + rid_np, pos_np, rid_tp, pos_tp, ts); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqNpointTnpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "EverEqNpointTnpointPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return EverEqNpointTnpointPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTnpointNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTnpointNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..3e5ec5e1d5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTnpointNpointPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EverEqTnpointNpointPhysicalFunction::EverEqTnpointNpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts, PhysicalFunction rid2, PhysicalFunction pos2) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(rid1)); + paramFns.push_back(std::move(pos1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(rid2)); + paramFns.push_back(std::move(pos2)); +} + +VarVal EverEqTnpointNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid1 = paramFns[0].execute(record, arena).cast(); + auto pos1 = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto rid2 = paramFns[3].execute(record, arena).cast(); + auto pos2 = paramFns[4].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t rid1, double pos1, uint64_t ts, uint64_t rid2, double pos2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np1 = npoint_make((int64_t)rid1, pos1); + if (!np1) return 0.0; + Temporal* inst = (Temporal*)tnpointinst_make(np1, (TimestampTz)ts); + free(np1); + if (!inst) return 0.0; + Npoint* np2 = npoint_make((int64_t)rid2, pos2); + if (!np2) { free(inst); return 0.0; } + int r = ever_eq_tnpoint_npoint(inst, np2); + free(inst); free(np2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + rid1, pos1, ts, rid2, pos2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTnpointNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "EverEqTnpointNpointPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return EverEqTnpointNpointPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeNpointTnpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeNpointTnpointPhysicalFunction.cpp new file mode 100644 index 0000000000..35f9bd221c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeNpointTnpointPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EverNeNpointTnpointPhysicalFunction::EverNeNpointTnpointPhysicalFunction(PhysicalFunction rid_np, PhysicalFunction pos_np, PhysicalFunction rid_tp, PhysicalFunction pos_tp, PhysicalFunction ts) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(rid_np)); + paramFns.push_back(std::move(pos_np)); + paramFns.push_back(std::move(rid_tp)); + paramFns.push_back(std::move(pos_tp)); + paramFns.push_back(std::move(ts)); +} + +VarVal EverNeNpointTnpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid_np = paramFns[0].execute(record, arena).cast(); + auto pos_np = paramFns[1].execute(record, arena).cast(); + auto rid_tp = paramFns[2].execute(record, arena).cast(); + auto pos_tp = paramFns[3].execute(record, arena).cast(); + auto ts = paramFns[4].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t rid_np, double pos_np, uint64_t rid_tp, double pos_tp, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np_s = npoint_make((int64_t)rid_np, pos_np); + if (!np_s) return 0.0; + Npoint* np_t = npoint_make((int64_t)rid_tp, pos_tp); + if (!np_t) { free(np_s); return 0.0; } + Temporal* inst = (Temporal*)tnpointinst_make(np_t, (TimestampTz)ts); + free(np_t); + if (!inst) { free(np_s); return 0.0; } + int r = ever_ne_npoint_tnpoint(np_s, inst); + free(np_s); free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + rid_np, pos_np, rid_tp, pos_tp, ts); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeNpointTnpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "EverNeNpointTnpointPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return EverNeNpointTnpointPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTnpointNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTnpointNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..fcdd0cdab9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTnpointNpointPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EverNeTnpointNpointPhysicalFunction::EverNeTnpointNpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts, PhysicalFunction rid2, PhysicalFunction pos2) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(rid1)); + paramFns.push_back(std::move(pos1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(rid2)); + paramFns.push_back(std::move(pos2)); +} + +VarVal EverNeTnpointNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid1 = paramFns[0].execute(record, arena).cast(); + auto pos1 = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto rid2 = paramFns[3].execute(record, arena).cast(); + auto pos2 = paramFns[4].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t rid1, double pos1, uint64_t ts, uint64_t rid2, double pos2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np1 = npoint_make((int64_t)rid1, pos1); + if (!np1) return 0.0; + Temporal* inst = (Temporal*)tnpointinst_make(np1, (TimestampTz)ts); + free(np1); + if (!inst) return 0.0; + Npoint* np2 = npoint_make((int64_t)rid2, pos2); + if (!np2) { free(inst); return 0.0; } + int r = ever_ne_tnpoint_npoint(inst, np2); + free(inst); free(np2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + rid1, pos1, ts, rid2, pos2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTnpointNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "EverNeTnpointNpointPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return EverNeTnpointNpointPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/NadTnpointGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/NadTnpointGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..f56b5303df --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/NadTnpointGeoPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +NadTnpointGeoPhysicalFunction::NadTnpointGeoPhysicalFunction(PhysicalFunction rid, PhysicalFunction pos, PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(rid)); + paramFns.push_back(std::move(pos)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal NadTnpointGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid = paramFns[0].execute(record, arena).cast(); + auto pos = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto wkt = paramFns[3].execute(record, arena); + const auto result = nautilus::invoke( + +[](uint64_t rid, double pos, uint64_t ts, const char* wkt, uint32_t wkt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np = npoint_make((int64_t)rid, pos); + if (!np) return 0.0; + Temporal* inst = (Temporal*)tnpointinst_make(np, (TimestampTz)ts); + free(np); + if (!inst) return 0.0; + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!gs) { free(inst); return 0.0; } + double r = nad_tnpoint_geo(inst, gs); + free(inst); free(gs); + return r; + } catch (const std::exception&) { return 0.0; } + }, + rid, pos, ts, wkt); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterNadTnpointGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "NadTnpointGeoPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return NadTnpointGeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/NadTnpointNpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/NadTnpointNpointPhysicalFunction.cpp new file mode 100644 index 0000000000..52016d483a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/NadTnpointNpointPhysicalFunction.cpp @@ -0,0 +1,88 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +NadTnpointNpointPhysicalFunction::NadTnpointNpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts, PhysicalFunction rid2, PhysicalFunction pos2) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(rid1)); + paramFns.push_back(std::move(pos1)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(rid2)); + paramFns.push_back(std::move(pos2)); +} + +VarVal NadTnpointNpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid1 = paramFns[0].execute(record, arena).cast(); + auto pos1 = paramFns[1].execute(record, arena).cast(); + auto ts = paramFns[2].execute(record, arena).cast(); + auto rid2 = paramFns[3].execute(record, arena).cast(); + auto pos2 = paramFns[4].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t rid1, double pos1, uint64_t ts, uint64_t rid2, double pos2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np1 = npoint_make((int64_t)rid1, pos1); + if (!np1) return 0.0; + Temporal* inst = (Temporal*)tnpointinst_make(np1, (TimestampTz)ts); + free(np1); + if (!inst) return 0.0; + Npoint* np2 = npoint_make((int64_t)rid2, pos2); + if (!np2) { free(inst); return 0.0; } + double r = nad_tnpoint_npoint(inst, np2); + free(inst); free(np2); + return r; + } catch (const std::exception&) { return 0.0; } + }, + rid1, pos1, ts, rid2, pos2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterNadTnpointNpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "NadTnpointNpointPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return NadTnpointNpointPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 5bbf4a6792..368afd38f5 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -850,6 +850,16 @@ NAD_TCBUFFER_TCBUFFER: 'NAD_TCBUFFER_TCBUFFER' | 'nad_tcbuffer_tcbuffer'; EDWITHIN_TCBUFFER_TCBUFFER: 'EDWITHIN_TCBUFFER_TCBUFFER' | 'edwithin_tcbuffer_tcbuffer'; ADWITHIN_TCBUFFER_TCBUFFER: 'ADWITHIN_TCBUFFER_TCBUFFER' | 'adwithin_tcbuffer_tcbuffer'; MINDISTANCE_TCBUFFER_TCBUFFER: 'MINDISTANCE_TCBUFFER_TCBUFFER' | 'mindistance_tcbuffer_tcbuffer'; +NAD_TNPOINT_GEO: 'NAD_TNPOINT_GEO' | 'nad_tnpoint_geo'; +EVER_EQ_TNPOINT_NPOINT: 'EVER_EQ_TNPOINT_NPOINT' | 'ever_eq_tnpoint_npoint'; +ALWAYS_EQ_TNPOINT_NPOINT: 'ALWAYS_EQ_TNPOINT_NPOINT' | 'always_eq_tnpoint_npoint'; +EVER_NE_TNPOINT_NPOINT: 'EVER_NE_TNPOINT_NPOINT' | 'ever_ne_tnpoint_npoint'; +ALWAYS_NE_TNPOINT_NPOINT: 'ALWAYS_NE_TNPOINT_NPOINT' | 'always_ne_tnpoint_npoint'; +NAD_TNPOINT_NPOINT: 'NAD_TNPOINT_NPOINT' | 'nad_tnpoint_npoint'; +EVER_EQ_NPOINT_TNPOINT: 'EVER_EQ_NPOINT_TNPOINT' | 'ever_eq_npoint_tnpoint'; +ALWAYS_EQ_NPOINT_TNPOINT: 'ALWAYS_EQ_NPOINT_TNPOINT' | 'always_eq_npoint_tnpoint'; +EVER_NE_NPOINT_TNPOINT: 'EVER_NE_NPOINT_TNPOINT' | 'ever_ne_npoint_tnpoint'; +ALWAYS_NE_NPOINT_TNPOINT: 'ALWAYS_NE_NPOINT_TNPOINT' | 'always_ne_npoint_tnpoint'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 99130e443e..fbe706f10c 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -431,6 +431,16 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -9933,6 +9943,125 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(MindistanceTcbufferTcbufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8))); } /* END CODEGEN PARSER GLUE: MINDISTANCE_TCBUFFER_TCBUFFER */ + case AntlrSQLParser::NAD_TNPOINT_GEO: { + PRECONDITION(ctx->functionParam().size() == 4, + "NadTnpointGeo requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(NadTnpointGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: NAD_TNPOINT_GEO */ + case AntlrSQLParser::EVER_EQ_TNPOINT_NPOINT: { + PRECONDITION(ctx->functionParam().size() == 5, + "EverEqTnpointNpoint requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(EverEqTnpointNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_TNPOINT_NPOINT */ + case AntlrSQLParser::ALWAYS_EQ_TNPOINT_NPOINT: { + PRECONDITION(ctx->functionParam().size() == 5, + "AlwaysEqTnpointNpoint requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(AlwaysEqTnpointNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TNPOINT_NPOINT */ + case AntlrSQLParser::EVER_NE_TNPOINT_NPOINT: { + PRECONDITION(ctx->functionParam().size() == 5, + "EverNeTnpointNpoint requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(EverNeTnpointNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_TNPOINT_NPOINT */ + case AntlrSQLParser::ALWAYS_NE_TNPOINT_NPOINT: { + PRECONDITION(ctx->functionParam().size() == 5, + "AlwaysNeTnpointNpoint requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(AlwaysNeTnpointNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TNPOINT_NPOINT */ + case AntlrSQLParser::NAD_TNPOINT_NPOINT: { + PRECONDITION(ctx->functionParam().size() == 5, + "NadTnpointNpoint requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(NadTnpointNpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: NAD_TNPOINT_NPOINT */ + case AntlrSQLParser::EVER_EQ_NPOINT_TNPOINT: { + PRECONDITION(ctx->functionParam().size() == 5, + "EverEqNpointTnpoint requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(EverEqNpointTnpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_NPOINT_TNPOINT */ + case AntlrSQLParser::ALWAYS_EQ_NPOINT_TNPOINT: { + PRECONDITION(ctx->functionParam().size() == 5, + "AlwaysEqNpointTnpoint requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(AlwaysEqNpointTnpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_NPOINT_TNPOINT */ + case AntlrSQLParser::EVER_NE_NPOINT_TNPOINT: { + PRECONDITION(ctx->functionParam().size() == 5, + "EverNeNpointTnpoint requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(EverNeNpointTnpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_NPOINT_TNPOINT */ + case AntlrSQLParser::ALWAYS_NE_NPOINT_TNPOINT: { + PRECONDITION(ctx->functionParam().size() == 5, + "AlwaysNeNpointTnpoint requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(AlwaysNeNpointTnpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_NPOINT_TNPOINT */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 707c11d63b5299c0b329fa2e05114932729967c8 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 08:08:37 +0200 Subject: [PATCH 67/86] feat(meos): add tnpoint_tnpoint per-event scalar operators (W119) Wires five tnpoint-vs-tnpoint operators using a 6-arg all-numeric pattern (rid1:UINT64, pos1:FLOAT64, ts1:UINT64, rid2:UINT64, pos2:FLOAT64, ts2:UINT64) -> FLOAT64. Each physical function builds two tnpoint instants via npoint_make and tnpointinst_make. Operators: EVER_EQ/ALWAYS_EQ/EVER_NE/ALWAYS_NE _TNPOINT_TNPOINT (return 0.0/1.0), and NAD_TNPOINT_TNPOINT (nearest approach distance or -1.0 on error). --- .../AlwaysEqTnpointTnpointLogicalFunction.hpp | 52 ++++++++ .../AlwaysNeTnpointTnpointLogicalFunction.hpp | 52 ++++++++ .../EverEqTnpointTnpointLogicalFunction.hpp | 52 ++++++++ .../EverNeTnpointTnpointLogicalFunction.hpp | 52 ++++++++ .../Meos/NadTnpointTnpointLogicalFunction.hpp | 52 ++++++++ .../AlwaysEqTnpointTnpointLogicalFunction.cpp | 112 ++++++++++++++++++ .../AlwaysNeTnpointTnpointLogicalFunction.cpp | 112 ++++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../EverEqTnpointTnpointLogicalFunction.cpp | 112 ++++++++++++++++++ .../EverNeTnpointTnpointLogicalFunction.cpp | 112 ++++++++++++++++++ .../Meos/NadTnpointTnpointLogicalFunction.cpp | 112 ++++++++++++++++++ ...AlwaysEqTnpointTnpointPhysicalFunction.hpp | 33 ++++++ ...AlwaysNeTnpointTnpointPhysicalFunction.hpp | 33 ++++++ .../EverEqTnpointTnpointPhysicalFunction.hpp | 33 ++++++ .../EverNeTnpointTnpointPhysicalFunction.hpp | 33 ++++++ .../NadTnpointTnpointPhysicalFunction.hpp | 33 ++++++ ...AlwaysEqTnpointTnpointPhysicalFunction.cpp | 96 +++++++++++++++ ...AlwaysNeTnpointTnpointPhysicalFunction.cpp | 96 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../EverEqTnpointTnpointPhysicalFunction.cpp | 96 +++++++++++++++ .../EverNeTnpointTnpointPhysicalFunction.cpp | 96 +++++++++++++++ .../NadTnpointTnpointPhysicalFunction.cpp | 96 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 7 +- .../src/AntlrSQLQueryPlanCreator.cpp | 70 +++++++++++ 24 files changed, 1551 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTnpointTnpointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTnpointTnpointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTnpointTnpointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTnpointTnpointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/NadTnpointTnpointLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTnpointTnpointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTnpointTnpointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTnpointTnpointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTnpointTnpointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/NadTnpointTnpointLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTnpointTnpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTnpointTnpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTnpointTnpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTnpointTnpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/NadTnpointTnpointPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTnpointTnpointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTnpointTnpointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTnpointTnpointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTnpointTnpointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/NadTnpointTnpointPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTnpointTnpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTnpointTnpointLogicalFunction.hpp new file mode 100644 index 0000000000..550d19e5ef --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTnpointTnpointLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tnpoint instants are always equal, 0.0 otherwise. + * + * Args: (rid1:UINT64, pos1:FLOAT64, ts1:UINT64, + * rid2:UINT64, pos2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class AlwaysEqTnpointTnpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTnpointTnpoint"; + + AlwaysEqTnpointTnpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts1, + LogicalFunction rid2, LogicalFunction pos2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTnpointTnpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTnpointTnpointLogicalFunction.hpp new file mode 100644 index 0000000000..01aa7bc348 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTnpointTnpointLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tnpoint instants are always not equal, 0.0 otherwise. + * + * Args: (rid1:UINT64, pos1:FLOAT64, ts1:UINT64, + * rid2:UINT64, pos2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class AlwaysNeTnpointTnpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTnpointTnpoint"; + + AlwaysNeTnpointTnpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts1, + LogicalFunction rid2, LogicalFunction pos2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTnpointTnpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTnpointTnpointLogicalFunction.hpp new file mode 100644 index 0000000000..83955bbd65 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTnpointTnpointLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tnpoint instants are ever equal, 0.0 otherwise. + * + * Args: (rid1:UINT64, pos1:FLOAT64, ts1:UINT64, + * rid2:UINT64, pos2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class EverEqTnpointTnpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTnpointTnpoint"; + + EverEqTnpointTnpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts1, + LogicalFunction rid2, LogicalFunction pos2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTnpointTnpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTnpointTnpointLogicalFunction.hpp new file mode 100644 index 0000000000..70b4eb871e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTnpointTnpointLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tnpoint instants are ever not equal, 0.0 otherwise. + * + * Args: (rid1:UINT64, pos1:FLOAT64, ts1:UINT64, + * rid2:UINT64, pos2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class EverNeTnpointTnpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTnpointTnpoint"; + + EverNeTnpointTnpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts1, + LogicalFunction rid2, LogicalFunction pos2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/NadTnpointTnpointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/NadTnpointTnpointLogicalFunction.hpp new file mode 100644 index 0000000000..df02072219 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/NadTnpointTnpointLogicalFunction.hpp @@ -0,0 +1,52 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nearest approach distance between two tnpoint instants. + * + * Args: (rid1:UINT64, pos1:FLOAT64, ts1:UINT64, + * rid2:UINT64, pos2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class NadTnpointTnpointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "NadTnpointTnpoint"; + + NadTnpointTnpointLogicalFunction(LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts1, + LogicalFunction rid2, LogicalFunction pos2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTnpointTnpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTnpointTnpointLogicalFunction.cpp new file mode 100644 index 0000000000..5d2ef221c8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTnpointTnpointLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTnpointTnpointLogicalFunction::AlwaysEqTnpointTnpointLogicalFunction( + LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts1, + LogicalFunction rid2, LogicalFunction pos2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(rid1)); + parameters.push_back(std::move(pos1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(rid2)); + parameters.push_back(std::move(pos2)); + parameters.push_back(std::move(ts2)); +} + +DataType AlwaysEqTnpointTnpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTnpointTnpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTnpointTnpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTnpointTnpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AlwaysEqTnpointTnpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTnpointTnpointLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTnpointTnpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTnpointTnpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqTnpointTnpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid1 must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "rid2 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "pos2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysEqTnpointTnpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTnpointTnpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AlwaysEqTnpointTnpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AlwaysEqTnpointTnpointLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTnpointTnpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTnpointTnpointLogicalFunction.cpp new file mode 100644 index 0000000000..0691b0129c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTnpointTnpointLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTnpointTnpointLogicalFunction::AlwaysNeTnpointTnpointLogicalFunction( + LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts1, + LogicalFunction rid2, LogicalFunction pos2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(rid1)); + parameters.push_back(std::move(pos1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(rid2)); + parameters.push_back(std::move(pos2)); + parameters.push_back(std::move(ts2)); +} + +DataType AlwaysNeTnpointTnpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTnpointTnpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTnpointTnpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTnpointTnpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AlwaysNeTnpointTnpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTnpointTnpointLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTnpointTnpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTnpointTnpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeTnpointTnpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid1 must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "rid2 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "pos2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysNeTnpointTnpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTnpointTnpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AlwaysNeTnpointTnpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AlwaysNeTnpointTnpointLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 76816ac322..a45f610e8d 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -390,6 +390,11 @@ add_plugin(EverEqNpointTnpoint LogicalFunction nes-logical-operators EverEqNpoin add_plugin(AlwaysEqNpointTnpoint LogicalFunction nes-logical-operators AlwaysEqNpointTnpointLogicalFunction.cpp) add_plugin(EverNeNpointTnpoint LogicalFunction nes-logical-operators EverNeNpointTnpointLogicalFunction.cpp) add_plugin(AlwaysNeNpointTnpoint LogicalFunction nes-logical-operators AlwaysNeNpointTnpointLogicalFunction.cpp) +add_plugin(EverEqTnpointTnpoint LogicalFunction nes-logical-operators EverEqTnpointTnpointLogicalFunction.cpp) +add_plugin(AlwaysEqTnpointTnpoint LogicalFunction nes-logical-operators AlwaysEqTnpointTnpointLogicalFunction.cpp) +add_plugin(EverNeTnpointTnpoint LogicalFunction nes-logical-operators EverNeTnpointTnpointLogicalFunction.cpp) +add_plugin(AlwaysNeTnpointTnpoint LogicalFunction nes-logical-operators AlwaysNeTnpointTnpointLogicalFunction.cpp) +add_plugin(NadTnpointTnpoint LogicalFunction nes-logical-operators NadTnpointTnpointLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTnpointTnpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTnpointTnpointLogicalFunction.cpp new file mode 100644 index 0000000000..78af507a03 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTnpointTnpointLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTnpointTnpointLogicalFunction::EverEqTnpointTnpointLogicalFunction( + LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts1, + LogicalFunction rid2, LogicalFunction pos2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(rid1)); + parameters.push_back(std::move(pos1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(rid2)); + parameters.push_back(std::move(pos2)); + parameters.push_back(std::move(ts2)); +} + +DataType EverEqTnpointTnpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTnpointTnpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTnpointTnpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTnpointTnpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EverEqTnpointTnpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTnpointTnpointLogicalFunction::getType() const { return NAME; } + +bool EverEqTnpointTnpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTnpointTnpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqTnpointTnpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid1 must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "rid2 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "pos2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverEqTnpointTnpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTnpointTnpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EverEqTnpointTnpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EverEqTnpointTnpointLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTnpointTnpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTnpointTnpointLogicalFunction.cpp new file mode 100644 index 0000000000..74c753b89c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTnpointTnpointLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTnpointTnpointLogicalFunction::EverNeTnpointTnpointLogicalFunction( + LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts1, + LogicalFunction rid2, LogicalFunction pos2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(rid1)); + parameters.push_back(std::move(pos1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(rid2)); + parameters.push_back(std::move(pos2)); + parameters.push_back(std::move(ts2)); +} + +DataType EverNeTnpointTnpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTnpointTnpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTnpointTnpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTnpointTnpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EverNeTnpointTnpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTnpointTnpointLogicalFunction::getType() const { return NAME; } + +bool EverNeTnpointTnpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTnpointTnpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeTnpointTnpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid1 must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "rid2 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "pos2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverNeTnpointTnpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTnpointTnpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EverNeTnpointTnpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EverNeTnpointTnpointLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/NadTnpointTnpointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/NadTnpointTnpointLogicalFunction.cpp new file mode 100644 index 0000000000..64a45be719 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/NadTnpointTnpointLogicalFunction.cpp @@ -0,0 +1,112 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +NadTnpointTnpointLogicalFunction::NadTnpointTnpointLogicalFunction( + LogicalFunction rid1, LogicalFunction pos1, LogicalFunction ts1, + LogicalFunction rid2, LogicalFunction pos2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(rid1)); + parameters.push_back(std::move(pos1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(rid2)); + parameters.push_back(std::move(pos2)); + parameters.push_back(std::move(ts2)); +} + +DataType NadTnpointTnpointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction NadTnpointTnpointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector NadTnpointTnpointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction NadTnpointTnpointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "NadTnpointTnpointLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view NadTnpointTnpointLogicalFunction::getType() const { return NAME; } + +bool NadTnpointTnpointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string NadTnpointTnpointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction NadTnpointTnpointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "rid1 must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "pos1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "rid2 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "pos2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction NadTnpointTnpointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterNadTnpointTnpointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "NadTnpointTnpointLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return NadTnpointTnpointLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTnpointTnpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTnpointTnpointPhysicalFunction.hpp new file mode 100644 index 0000000000..550ab6cd9a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTnpointTnpointPhysicalFunction.hpp @@ -0,0 +1,33 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTnpointTnpointPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTnpointTnpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts1, + PhysicalFunction rid2, PhysicalFunction pos2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTnpointTnpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTnpointTnpointPhysicalFunction.hpp new file mode 100644 index 0000000000..f06db451c4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTnpointTnpointPhysicalFunction.hpp @@ -0,0 +1,33 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTnpointTnpointPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTnpointTnpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts1, + PhysicalFunction rid2, PhysicalFunction pos2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTnpointTnpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTnpointTnpointPhysicalFunction.hpp new file mode 100644 index 0000000000..d4bca5295e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTnpointTnpointPhysicalFunction.hpp @@ -0,0 +1,33 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTnpointTnpointPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTnpointTnpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts1, + PhysicalFunction rid2, PhysicalFunction pos2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTnpointTnpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTnpointTnpointPhysicalFunction.hpp new file mode 100644 index 0000000000..3647332d45 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTnpointTnpointPhysicalFunction.hpp @@ -0,0 +1,33 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTnpointTnpointPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTnpointTnpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts1, + PhysicalFunction rid2, PhysicalFunction pos2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/NadTnpointTnpointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/NadTnpointTnpointPhysicalFunction.hpp new file mode 100644 index 0000000000..d6819b22ef --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/NadTnpointTnpointPhysicalFunction.hpp @@ -0,0 +1,33 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class NadTnpointTnpointPhysicalFunction : public PhysicalFunctionConcept { +public: + NadTnpointTnpointPhysicalFunction(PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts1, + PhysicalFunction rid2, PhysicalFunction pos2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTnpointTnpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTnpointTnpointPhysicalFunction.cpp new file mode 100644 index 0000000000..3f5955d6b2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTnpointTnpointPhysicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTnpointTnpointPhysicalFunction::AlwaysEqTnpointTnpointPhysicalFunction( + PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts1, + PhysicalFunction rid2, PhysicalFunction pos2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(rid1)); + paramFns.push_back(std::move(pos1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(rid2)); + paramFns.push_back(std::move(pos2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AlwaysEqTnpointTnpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid1 = paramFns[0].execute(record, arena).cast(); + auto pos1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto rid2 = paramFns[3].execute(record, arena).cast(); + auto pos2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t rid1, double pos1, uint64_t ts1, + uint64_t rid2, double pos2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np1 = npoint_make((int64_t)rid1, pos1); + if (!np1) return 0.0; + Temporal* inst1 = (Temporal*)tnpointinst_make(np1, (TimestampTz)ts1); + free(np1); + if (!inst1) return 0.0; + Npoint* np2 = npoint_make((int64_t)rid2, pos2); + if (!np2) { free(inst1); return 0.0; } + Temporal* inst2 = (Temporal*)tnpointinst_make(np2, (TimestampTz)ts2); + free(np2); + if (!inst2) { free(inst1); return 0.0; } + int r = always_eq_tnpoint_tnpoint(inst1, inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + rid1, pos1, ts1, rid2, pos2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTnpointTnpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AlwaysEqTnpointTnpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTnpointTnpointPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTnpointTnpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTnpointTnpointPhysicalFunction.cpp new file mode 100644 index 0000000000..1ee5511def --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTnpointTnpointPhysicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTnpointTnpointPhysicalFunction::AlwaysNeTnpointTnpointPhysicalFunction( + PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts1, + PhysicalFunction rid2, PhysicalFunction pos2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(rid1)); + paramFns.push_back(std::move(pos1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(rid2)); + paramFns.push_back(std::move(pos2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AlwaysNeTnpointTnpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid1 = paramFns[0].execute(record, arena).cast(); + auto pos1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto rid2 = paramFns[3].execute(record, arena).cast(); + auto pos2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t rid1, double pos1, uint64_t ts1, + uint64_t rid2, double pos2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np1 = npoint_make((int64_t)rid1, pos1); + if (!np1) return 0.0; + Temporal* inst1 = (Temporal*)tnpointinst_make(np1, (TimestampTz)ts1); + free(np1); + if (!inst1) return 0.0; + Npoint* np2 = npoint_make((int64_t)rid2, pos2); + if (!np2) { free(inst1); return 0.0; } + Temporal* inst2 = (Temporal*)tnpointinst_make(np2, (TimestampTz)ts2); + free(np2); + if (!inst2) { free(inst1); return 0.0; } + int r = always_ne_tnpoint_tnpoint(inst1, inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + rid1, pos1, ts1, rid2, pos2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTnpointTnpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AlwaysNeTnpointTnpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTnpointTnpointPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 9f072bfa7b..71b501da60 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -389,6 +389,11 @@ add_plugin(EverEqNpointTnpoint PhysicalFunction nes-physical-operators EverEqNpo add_plugin(AlwaysEqNpointTnpoint PhysicalFunction nes-physical-operators AlwaysEqNpointTnpointPhysicalFunction.cpp) add_plugin(EverNeNpointTnpoint PhysicalFunction nes-physical-operators EverNeNpointTnpointPhysicalFunction.cpp) add_plugin(AlwaysNeNpointTnpoint PhysicalFunction nes-physical-operators AlwaysNeNpointTnpointPhysicalFunction.cpp) +add_plugin(EverEqTnpointTnpoint PhysicalFunction nes-physical-operators EverEqTnpointTnpointPhysicalFunction.cpp) +add_plugin(AlwaysEqTnpointTnpoint PhysicalFunction nes-physical-operators AlwaysEqTnpointTnpointPhysicalFunction.cpp) +add_plugin(EverNeTnpointTnpoint PhysicalFunction nes-physical-operators EverNeTnpointTnpointPhysicalFunction.cpp) +add_plugin(AlwaysNeTnpointTnpoint PhysicalFunction nes-physical-operators AlwaysNeTnpointTnpointPhysicalFunction.cpp) +add_plugin(NadTnpointTnpoint PhysicalFunction nes-physical-operators NadTnpointTnpointPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTnpointTnpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTnpointTnpointPhysicalFunction.cpp new file mode 100644 index 0000000000..438f74a8b6 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTnpointTnpointPhysicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTnpointTnpointPhysicalFunction::EverEqTnpointTnpointPhysicalFunction( + PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts1, + PhysicalFunction rid2, PhysicalFunction pos2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(rid1)); + paramFns.push_back(std::move(pos1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(rid2)); + paramFns.push_back(std::move(pos2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EverEqTnpointTnpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid1 = paramFns[0].execute(record, arena).cast(); + auto pos1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto rid2 = paramFns[3].execute(record, arena).cast(); + auto pos2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t rid1, double pos1, uint64_t ts1, + uint64_t rid2, double pos2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np1 = npoint_make((int64_t)rid1, pos1); + if (!np1) return 0.0; + Temporal* inst1 = (Temporal*)tnpointinst_make(np1, (TimestampTz)ts1); + free(np1); + if (!inst1) return 0.0; + Npoint* np2 = npoint_make((int64_t)rid2, pos2); + if (!np2) { free(inst1); return 0.0; } + Temporal* inst2 = (Temporal*)tnpointinst_make(np2, (TimestampTz)ts2); + free(np2); + if (!inst2) { free(inst1); return 0.0; } + int r = ever_eq_tnpoint_tnpoint(inst1, inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + rid1, pos1, ts1, rid2, pos2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTnpointTnpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EverEqTnpointTnpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EverEqTnpointTnpointPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTnpointTnpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTnpointTnpointPhysicalFunction.cpp new file mode 100644 index 0000000000..96cde58e77 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTnpointTnpointPhysicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTnpointTnpointPhysicalFunction::EverNeTnpointTnpointPhysicalFunction( + PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts1, + PhysicalFunction rid2, PhysicalFunction pos2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(rid1)); + paramFns.push_back(std::move(pos1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(rid2)); + paramFns.push_back(std::move(pos2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EverNeTnpointTnpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid1 = paramFns[0].execute(record, arena).cast(); + auto pos1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto rid2 = paramFns[3].execute(record, arena).cast(); + auto pos2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t rid1, double pos1, uint64_t ts1, + uint64_t rid2, double pos2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np1 = npoint_make((int64_t)rid1, pos1); + if (!np1) return 0.0; + Temporal* inst1 = (Temporal*)tnpointinst_make(np1, (TimestampTz)ts1); + free(np1); + if (!inst1) return 0.0; + Npoint* np2 = npoint_make((int64_t)rid2, pos2); + if (!np2) { free(inst1); return 0.0; } + Temporal* inst2 = (Temporal*)tnpointinst_make(np2, (TimestampTz)ts2); + free(np2); + if (!inst2) { free(inst1); return 0.0; } + int r = ever_ne_tnpoint_tnpoint(inst1, inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + rid1, pos1, ts1, rid2, pos2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTnpointTnpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EverNeTnpointTnpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EverNeTnpointTnpointPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/NadTnpointTnpointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/NadTnpointTnpointPhysicalFunction.cpp new file mode 100644 index 0000000000..b126f6b1bf --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/NadTnpointTnpointPhysicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +NadTnpointTnpointPhysicalFunction::NadTnpointTnpointPhysicalFunction( + PhysicalFunction rid1, PhysicalFunction pos1, PhysicalFunction ts1, + PhysicalFunction rid2, PhysicalFunction pos2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(rid1)); + paramFns.push_back(std::move(pos1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(rid2)); + paramFns.push_back(std::move(pos2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal NadTnpointTnpointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto rid1 = paramFns[0].execute(record, arena).cast(); + auto pos1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto rid2 = paramFns[3].execute(record, arena).cast(); + auto pos2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](uint64_t rid1, double pos1, uint64_t ts1, + uint64_t rid2, double pos2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Npoint* np1 = npoint_make((int64_t)rid1, pos1); + if (!np1) return 0.0; + Temporal* inst1 = (Temporal*)tnpointinst_make(np1, (TimestampTz)ts1); + free(np1); + if (!inst1) return 0.0; + Npoint* np2 = npoint_make((int64_t)rid2, pos2); + if (!np2) { free(inst1); return 0.0; } + Temporal* inst2 = (Temporal*)tnpointinst_make(np2, (TimestampTz)ts2); + free(np2); + if (!inst2) { free(inst1); return 0.0; } + double r = nad_tnpoint_tnpoint(inst1, inst2); + free(inst1); free(inst2); + return r; + } catch (const std::exception&) { return -1.0; } + }, + rid1, pos1, ts1, rid2, pos2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterNadTnpointTnpointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "NadTnpointTnpointPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return NadTnpointTnpointPhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 368afd38f5..e7d8aabfd5 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -860,6 +860,11 @@ EVER_EQ_NPOINT_TNPOINT: 'EVER_EQ_NPOINT_TNPOINT' | 'ever_eq_npoint_tnpoint'; ALWAYS_EQ_NPOINT_TNPOINT: 'ALWAYS_EQ_NPOINT_TNPOINT' | 'always_eq_npoint_tnpoint'; EVER_NE_NPOINT_TNPOINT: 'EVER_NE_NPOINT_TNPOINT' | 'ever_ne_npoint_tnpoint'; ALWAYS_NE_NPOINT_TNPOINT: 'ALWAYS_NE_NPOINT_TNPOINT' | 'always_ne_npoint_tnpoint'; +EVER_EQ_TNPOINT_TNPOINT: 'EVER_EQ_TNPOINT_TNPOINT' | 'ever_eq_tnpoint_tnpoint'; +ALWAYS_EQ_TNPOINT_TNPOINT: 'ALWAYS_EQ_TNPOINT_TNPOINT' | 'always_eq_tnpoint_tnpoint'; +EVER_NE_TNPOINT_TNPOINT: 'EVER_NE_TNPOINT_TNPOINT' | 'ever_ne_tnpoint_tnpoint'; +ALWAYS_NE_TNPOINT_TNPOINT: 'ALWAYS_NE_TNPOINT_TNPOINT' | 'always_ne_tnpoint_tnpoint'; +NAD_TNPOINT_TNPOINT: 'NAD_TNPOINT_TNPOINT' | 'nad_tnpoint_tnpoint'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index fbe706f10c..94f98122e2 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -441,6 +441,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -10062,6 +10067,71 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(AlwaysNeNpointTnpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); } /* END CODEGEN PARSER GLUE: ALWAYS_NE_NPOINT_TNPOINT */ + case AntlrSQLParser::EVER_EQ_TNPOINT_TNPOINT: { + PRECONDITION(ctx->functionParam().size() == 6, + "EverEqTnpointTnpoint requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EverEqTnpointTnpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_TNPOINT_TNPOINT */ + case AntlrSQLParser::ALWAYS_EQ_TNPOINT_TNPOINT: { + PRECONDITION(ctx->functionParam().size() == 6, + "AlwaysEqTnpointTnpoint requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AlwaysEqTnpointTnpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TNPOINT_TNPOINT */ + case AntlrSQLParser::EVER_NE_TNPOINT_TNPOINT: { + PRECONDITION(ctx->functionParam().size() == 6, + "EverNeTnpointTnpoint requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EverNeTnpointTnpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_TNPOINT_TNPOINT */ + case AntlrSQLParser::ALWAYS_NE_TNPOINT_TNPOINT: { + PRECONDITION(ctx->functionParam().size() == 6, + "AlwaysNeTnpointTnpoint requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AlwaysNeTnpointTnpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TNPOINT_TNPOINT */ + case AntlrSQLParser::NAD_TNPOINT_TNPOINT: { + PRECONDITION(ctx->functionParam().size() == 6, + "NadTnpointTnpoint requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(NadTnpointTnpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: NAD_TNPOINT_TNPOINT */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From db23cc9fa17bd7cfe5c997305e6cab89400d1b5e Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 08:57:46 +0200 Subject: [PATCH 68/86] feat(meos): add tpose 2D per-event scalar operators for geo and pose (W120) Wires ten tpose operators using three new patterns for 2D poses. A tpose 2D instant is represented as (x:FLOAT64, y:FLOAT64, theta:FLOAT64, ts:UINT64) and built via pose_make_2d(x,y,theta,false,0) then tposeinst_make. Pattern A (5-arg with VARCHAR: x,y,theta,ts,wkt): NAD_TPOSE_GEO. Pattern B (7-arg tpose- first: x,y,theta,ts,x2,y2,theta2): EVER_EQ/ALWAYS_EQ/EVER_NE/ALWAYS_NE/NAD _TPOSE_POSE. Pattern C (7-arg pose-first reversed: x2,y2,theta2,x,y,theta,ts): EVER_EQ/ALWAYS_EQ/EVER_NE/ALWAYS_NE _POSE_TPOSE. --- .../Meos/AlwaysEqPoseTposeLogicalFunction.hpp | 48 ++++++ .../Meos/AlwaysEqTposePoseLogicalFunction.hpp | 48 ++++++ .../Meos/AlwaysNePoseTposeLogicalFunction.hpp | 48 ++++++ .../Meos/AlwaysNeTposePoseLogicalFunction.hpp | 48 ++++++ .../Meos/EverEqPoseTposeLogicalFunction.hpp | 48 ++++++ .../Meos/EverEqTposePoseLogicalFunction.hpp | 48 ++++++ .../Meos/EverNePoseTposeLogicalFunction.hpp | 48 ++++++ .../Meos/EverNeTposePoseLogicalFunction.hpp | 48 ++++++ .../Meos/NadTposeGeoLogicalFunction.hpp | 48 ++++++ .../Meos/NadTposePoseLogicalFunction.hpp | 48 ++++++ .../Meos/AlwaysEqPoseTposeLogicalFunction.cpp | 114 ++++++++++++++ .../Meos/AlwaysEqTposePoseLogicalFunction.cpp | 114 ++++++++++++++ .../Meos/AlwaysNePoseTposeLogicalFunction.cpp | 114 ++++++++++++++ .../Meos/AlwaysNeTposePoseLogicalFunction.cpp | 114 ++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 10 ++ .../Meos/EverEqPoseTposeLogicalFunction.cpp | 114 ++++++++++++++ .../Meos/EverEqTposePoseLogicalFunction.cpp | 114 ++++++++++++++ .../Meos/EverNePoseTposeLogicalFunction.cpp | 114 ++++++++++++++ .../Meos/EverNeTposePoseLogicalFunction.cpp | 114 ++++++++++++++ .../Meos/NadTposeGeoLogicalFunction.cpp | 108 +++++++++++++ .../Meos/NadTposePoseLogicalFunction.cpp | 114 ++++++++++++++ .../AlwaysEqPoseTposePhysicalFunction.hpp | 32 ++++ .../AlwaysEqTposePosePhysicalFunction.hpp | 32 ++++ .../AlwaysNePoseTposePhysicalFunction.hpp | 32 ++++ .../AlwaysNeTposePosePhysicalFunction.hpp | 32 ++++ .../Meos/EverEqPoseTposePhysicalFunction.hpp | 32 ++++ .../Meos/EverEqTposePosePhysicalFunction.hpp | 32 ++++ .../Meos/EverNePoseTposePhysicalFunction.hpp | 32 ++++ .../Meos/EverNeTposePosePhysicalFunction.hpp | 32 ++++ .../Meos/NadTposeGeoPhysicalFunction.hpp | 32 ++++ .../Meos/NadTposePosePhysicalFunction.hpp | 32 ++++ .../AlwaysEqPoseTposePhysicalFunction.cpp | 94 +++++++++++ .../AlwaysEqTposePosePhysicalFunction.cpp | 94 +++++++++++ .../AlwaysNePoseTposePhysicalFunction.cpp | 94 +++++++++++ .../AlwaysNeTposePosePhysicalFunction.cpp | 94 +++++++++++ .../src/Functions/Meos/CMakeLists.txt | 10 ++ .../Meos/EverEqPoseTposePhysicalFunction.cpp | 94 +++++++++++ .../Meos/EverEqTposePosePhysicalFunction.cpp | 94 +++++++++++ .../Meos/EverNePoseTposePhysicalFunction.cpp | 94 +++++++++++ .../Meos/EverNeTposePosePhysicalFunction.cpp | 94 +++++++++++ .../Meos/NadTposeGeoPhysicalFunction.cpp | 92 +++++++++++ .../Meos/NadTposePosePhysicalFunction.cpp | 94 +++++++++++ nes-sql-parser/AntlrSQL.g4 | 12 +- .../src/AntlrSQLQueryPlanCreator.cpp | 148 ++++++++++++++++++ 44 files changed, 3051 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqPoseTposeLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTposePoseLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNePoseTposeLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTposePoseLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqPoseTposeLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTposePoseLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNePoseTposeLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTposePoseLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/NadTposeGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/NadTposePoseLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqPoseTposeLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTposePoseLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNePoseTposeLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTposePoseLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqPoseTposeLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTposePoseLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNePoseTposeLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTposePoseLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/NadTposeGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/NadTposePoseLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqPoseTposePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTposePosePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNePoseTposePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTposePosePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqPoseTposePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTposePosePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNePoseTposePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTposePosePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/NadTposeGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/NadTposePosePhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqPoseTposePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTposePosePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNePoseTposePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTposePosePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqPoseTposePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTposePosePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNePoseTposePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTposePosePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/NadTposeGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/NadTposePosePhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqPoseTposeLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqPoseTposeLogicalFunction.hpp new file mode 100644 index 0000000000..6e2ad749d8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqPoseTposeLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the static pose is always equal to the 2D tpose instant, 0.0 otherwise. + */ +class AlwaysEqPoseTposeLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqPoseTpose"; + + AlwaysEqPoseTposeLogicalFunction(LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTposePoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTposePoseLogicalFunction.hpp new file mode 100644 index 0000000000..80eeee56b3 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTposePoseLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the 2D tpose instant is always equal to the static pose, 0.0 otherwise. + */ +class AlwaysEqTposePoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTposePose"; + + AlwaysEqTposePoseLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNePoseTposeLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNePoseTposeLogicalFunction.hpp new file mode 100644 index 0000000000..d604ce1f74 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNePoseTposeLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the static pose is always not equal to the 2D tpose instant, 0.0 otherwise. + */ +class AlwaysNePoseTposeLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNePoseTpose"; + + AlwaysNePoseTposeLogicalFunction(LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTposePoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTposePoseLogicalFunction.hpp new file mode 100644 index 0000000000..b26b209ec1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTposePoseLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the 2D tpose instant is always not equal to the static pose, 0.0 otherwise. + */ +class AlwaysNeTposePoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTposePose"; + + AlwaysNeTposePoseLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqPoseTposeLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqPoseTposeLogicalFunction.hpp new file mode 100644 index 0000000000..da75e450e1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqPoseTposeLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the static pose is ever equal to the 2D tpose instant, 0.0 otherwise. + */ +class EverEqPoseTposeLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqPoseTpose"; + + EverEqPoseTposeLogicalFunction(LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTposePoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTposePoseLogicalFunction.hpp new file mode 100644 index 0000000000..4b786a6452 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTposePoseLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the 2D tpose instant is ever equal to the static pose, 0.0 otherwise. + */ +class EverEqTposePoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTposePose"; + + EverEqTposePoseLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNePoseTposeLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNePoseTposeLogicalFunction.hpp new file mode 100644 index 0000000000..94e76a2718 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNePoseTposeLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the static pose is ever not equal to the 2D tpose instant, 0.0 otherwise. + */ +class EverNePoseTposeLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNePoseTpose"; + + EverNePoseTposeLogicalFunction(LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTposePoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTposePoseLogicalFunction.hpp new file mode 100644 index 0000000000..e94c0bded7 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTposePoseLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the 2D tpose instant is ever not equal to the static pose, 0.0 otherwise. + */ +class EverNeTposePoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTposePose"; + + EverNeTposePoseLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/NadTposeGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/NadTposeGeoLogicalFunction.hpp new file mode 100644 index 0000000000..72614db99c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/NadTposeGeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nearest approach distance between a 2D tpose instant and a static geometry. + */ +class NadTposeGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "NadTposeGeo"; + + NadTposeGeoLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/NadTposePoseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/NadTposePoseLogicalFunction.hpp new file mode 100644 index 0000000000..bccd5f063a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/NadTposePoseLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nearest approach distance between a 2D tpose instant and a static pose. + */ +class NadTposePoseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "NadTposePose"; + + NadTposePoseLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqPoseTposeLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqPoseTposeLogicalFunction.cpp new file mode 100644 index 0000000000..a6375f3a30 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqPoseTposeLogicalFunction.cpp @@ -0,0 +1,114 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqPoseTposeLogicalFunction::AlwaysEqPoseTposeLogicalFunction(LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqPoseTposeLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqPoseTposeLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqPoseTposeLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqPoseTposeLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "AlwaysEqPoseTposeLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqPoseTposeLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqPoseTposeLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqPoseTposeLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqPoseTposeLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysEqPoseTposeLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqPoseTposeLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "AlwaysEqPoseTposeLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return AlwaysEqPoseTposeLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTposePoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTposePoseLogicalFunction.cpp new file mode 100644 index 0000000000..8fa49b257f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTposePoseLogicalFunction.cpp @@ -0,0 +1,114 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTposePoseLogicalFunction::AlwaysEqTposePoseLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); +} + +DataType AlwaysEqTposePoseLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTposePoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTposePoseLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTposePoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "AlwaysEqTposePoseLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTposePoseLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTposePoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTposePoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqTposePoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AlwaysEqTposePoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTposePoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "AlwaysEqTposePoseLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return AlwaysEqTposePoseLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNePoseTposeLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNePoseTposeLogicalFunction.cpp new file mode 100644 index 0000000000..60c8744bdd --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNePoseTposeLogicalFunction.cpp @@ -0,0 +1,114 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNePoseTposeLogicalFunction::AlwaysNePoseTposeLogicalFunction(LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNePoseTposeLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNePoseTposeLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNePoseTposeLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNePoseTposeLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "AlwaysNePoseTposeLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNePoseTposeLogicalFunction::getType() const { return NAME; } + +bool AlwaysNePoseTposeLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNePoseTposeLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNePoseTposeLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysNePoseTposeLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNePoseTposeLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "AlwaysNePoseTposeLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return AlwaysNePoseTposeLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTposePoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTposePoseLogicalFunction.cpp new file mode 100644 index 0000000000..c4a6e0ed28 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTposePoseLogicalFunction.cpp @@ -0,0 +1,114 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTposePoseLogicalFunction::AlwaysNeTposePoseLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); +} + +DataType AlwaysNeTposePoseLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTposePoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTposePoseLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTposePoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "AlwaysNeTposePoseLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTposePoseLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTposePoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTposePoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeTposePoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AlwaysNeTposePoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTposePoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "AlwaysNeTposePoseLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return AlwaysNeTposePoseLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index a45f610e8d..ac864b86b8 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -395,6 +395,16 @@ add_plugin(AlwaysEqTnpointTnpoint LogicalFunction nes-logical-operators AlwaysEq add_plugin(EverNeTnpointTnpoint LogicalFunction nes-logical-operators EverNeTnpointTnpointLogicalFunction.cpp) add_plugin(AlwaysNeTnpointTnpoint LogicalFunction nes-logical-operators AlwaysNeTnpointTnpointLogicalFunction.cpp) add_plugin(NadTnpointTnpoint LogicalFunction nes-logical-operators NadTnpointTnpointLogicalFunction.cpp) +add_plugin(NadTposeGeo LogicalFunction nes-logical-operators NadTposeGeoLogicalFunction.cpp) +add_plugin(EverEqTposePose LogicalFunction nes-logical-operators EverEqTposePoseLogicalFunction.cpp) +add_plugin(AlwaysEqTposePose LogicalFunction nes-logical-operators AlwaysEqTposePoseLogicalFunction.cpp) +add_plugin(EverNeTposePose LogicalFunction nes-logical-operators EverNeTposePoseLogicalFunction.cpp) +add_plugin(AlwaysNeTposePose LogicalFunction nes-logical-operators AlwaysNeTposePoseLogicalFunction.cpp) +add_plugin(NadTposePose LogicalFunction nes-logical-operators NadTposePoseLogicalFunction.cpp) +add_plugin(EverEqPoseTpose LogicalFunction nes-logical-operators EverEqPoseTposeLogicalFunction.cpp) +add_plugin(AlwaysEqPoseTpose LogicalFunction nes-logical-operators AlwaysEqPoseTposeLogicalFunction.cpp) +add_plugin(EverNePoseTpose LogicalFunction nes-logical-operators EverNePoseTposeLogicalFunction.cpp) +add_plugin(AlwaysNePoseTpose LogicalFunction nes-logical-operators AlwaysNePoseTposeLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqPoseTposeLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqPoseTposeLogicalFunction.cpp new file mode 100644 index 0000000000..32dcbb6be6 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqPoseTposeLogicalFunction.cpp @@ -0,0 +1,114 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqPoseTposeLogicalFunction::EverEqPoseTposeLogicalFunction(LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqPoseTposeLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqPoseTposeLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqPoseTposeLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqPoseTposeLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "EverEqPoseTposeLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqPoseTposeLogicalFunction::getType() const { return NAME; } + +bool EverEqPoseTposeLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqPoseTposeLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqPoseTposeLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverEqPoseTposeLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqPoseTposeLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "EverEqPoseTposeLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return EverEqPoseTposeLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTposePoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTposePoseLogicalFunction.cpp new file mode 100644 index 0000000000..a5b4200952 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTposePoseLogicalFunction.cpp @@ -0,0 +1,114 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTposePoseLogicalFunction::EverEqTposePoseLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); +} + +DataType EverEqTposePoseLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTposePoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTposePoseLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTposePoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "EverEqTposePoseLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTposePoseLogicalFunction::getType() const { return NAME; } + +bool EverEqTposePoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTposePoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqTposePoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EverEqTposePoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTposePoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "EverEqTposePoseLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return EverEqTposePoseLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNePoseTposeLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNePoseTposeLogicalFunction.cpp new file mode 100644 index 0000000000..dcbaca23e5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNePoseTposeLogicalFunction.cpp @@ -0,0 +1,114 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNePoseTposeLogicalFunction::EverNePoseTposeLogicalFunction(LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); +} + +DataType EverNePoseTposeLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNePoseTposeLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNePoseTposeLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNePoseTposeLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "EverNePoseTposeLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNePoseTposeLogicalFunction::getType() const { return NAME; } + +bool EverNePoseTposeLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNePoseTposeLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNePoseTposeLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverNePoseTposeLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNePoseTposeLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "EverNePoseTposeLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return EverNePoseTposeLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTposePoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTposePoseLogicalFunction.cpp new file mode 100644 index 0000000000..d55ec596d1 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTposePoseLogicalFunction.cpp @@ -0,0 +1,114 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTposePoseLogicalFunction::EverNeTposePoseLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); +} + +DataType EverNeTposePoseLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTposePoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTposePoseLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTposePoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "EverNeTposePoseLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTposePoseLogicalFunction::getType() const { return NAME; } + +bool EverNeTposePoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTposePoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeTposePoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EverNeTposePoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTposePoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "EverNeTposePoseLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return EverNeTposePoseLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/NadTposeGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/NadTposeGeoLogicalFunction.cpp new file mode 100644 index 0000000000..b32aea7cef --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/NadTposeGeoLogicalFunction.cpp @@ -0,0 +1,108 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +NadTposeGeoLogicalFunction::NadTposeGeoLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(5); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(wkt)); +} + +DataType NadTposeGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction NadTposeGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector NadTposeGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction NadTposeGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 5, + "NadTposeGeoLogicalFunction requires 5 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view NadTposeGeoLogicalFunction::getType() const { return NAME; } + +bool NadTposeGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string NadTposeGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction NadTposeGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(5); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction NadTposeGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterNadTposeGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 5, + "NadTposeGeoLogicalFunction requires 5 children but got {}", + arguments.children.size()); + return NadTposeGeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/NadTposePoseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/NadTposePoseLogicalFunction.cpp new file mode 100644 index 0000000000..d4647c9627 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/NadTposePoseLogicalFunction.cpp @@ -0,0 +1,114 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +NadTposePoseLogicalFunction::NadTposePoseLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); +} + +DataType NadTposePoseLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction NadTposePoseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector NadTposePoseLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction NadTposePoseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "NadTposePoseLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view NadTposePoseLogicalFunction::getType() const { return NAME; } + +bool NadTposePoseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string NadTposePoseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction NadTposePoseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction NadTposePoseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterNadTposePoseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "NadTposePoseLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return NadTposePoseLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqPoseTposePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqPoseTposePhysicalFunction.hpp new file mode 100644 index 0000000000..29adc32501 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqPoseTposePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqPoseTposePhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqPoseTposePhysicalFunction(PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTposePosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTposePosePhysicalFunction.hpp new file mode 100644 index 0000000000..4b12612425 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTposePosePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTposePosePhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTposePosePhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNePoseTposePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNePoseTposePhysicalFunction.hpp new file mode 100644 index 0000000000..771235ac8a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNePoseTposePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNePoseTposePhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNePoseTposePhysicalFunction(PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTposePosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTposePosePhysicalFunction.hpp new file mode 100644 index 0000000000..d5b11fc7bd --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTposePosePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTposePosePhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTposePosePhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqPoseTposePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqPoseTposePhysicalFunction.hpp new file mode 100644 index 0000000000..b8defb26a6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqPoseTposePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqPoseTposePhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqPoseTposePhysicalFunction(PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTposePosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTposePosePhysicalFunction.hpp new file mode 100644 index 0000000000..a304cc7b82 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTposePosePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTposePosePhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTposePosePhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNePoseTposePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNePoseTposePhysicalFunction.hpp new file mode 100644 index 0000000000..227b02aa36 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNePoseTposePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNePoseTposePhysicalFunction : public PhysicalFunctionConcept { +public: + EverNePoseTposePhysicalFunction(PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTposePosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTposePosePhysicalFunction.hpp new file mode 100644 index 0000000000..2a1d144bdc --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTposePosePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTposePosePhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTposePosePhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/NadTposeGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/NadTposeGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..55ad411307 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/NadTposeGeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class NadTposeGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + NadTposeGeoPhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/NadTposePosePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/NadTposePosePhysicalFunction.hpp new file mode 100644 index 0000000000..1f9ed513ba --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/NadTposePosePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class NadTposePosePhysicalFunction : public PhysicalFunctionConcept { +public: + NadTposePosePhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqPoseTposePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqPoseTposePhysicalFunction.cpp new file mode 100644 index 0000000000..036c8801dd --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqPoseTposePhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AlwaysEqPoseTposePhysicalFunction::AlwaysEqPoseTposePhysicalFunction(PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); +} + +VarVal AlwaysEqPoseTposePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x2 = paramFns[0].execute(record, arena).cast(); + auto y2 = paramFns[1].execute(record, arena).cast(); + auto theta2 = paramFns[2].execute(record, arena).cast(); + auto x = paramFns[3].execute(record, arena).cast(); + auto y = paramFns[4].execute(record, arena).cast(); + auto theta = paramFns[5].execute(record, arena).cast(); + auto ts = paramFns[6].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double x2, double y2, double theta2, double x, double y, double theta, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* pose_s = pose_make_2d(x2, y2, theta2, false, 0); + if (!pose_s) return 0.0; + Pose* pose_t = pose_make_2d(x, y, theta, false, 0); + if (!pose_t) { free(pose_s); return 0.0; } + Temporal* inst = (Temporal*)tposeinst_make(pose_t, (TimestampTz)ts); + free(pose_t); + if (!inst) { free(pose_s); return 0.0; } + int r = always_eq_pose_tpose(pose_s, inst); + free(pose_s); free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + x2, y2, theta2, x, y, theta, ts); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqPoseTposePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "AlwaysEqPoseTposePhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqPoseTposePhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTposePosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTposePosePhysicalFunction.cpp new file mode 100644 index 0000000000..72132c2984 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTposePosePhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AlwaysEqTposePosePhysicalFunction::AlwaysEqTposePosePhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); +} + +VarVal AlwaysEqTposePosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x = paramFns[0].execute(record, arena).cast(); + auto y = paramFns[1].execute(record, arena).cast(); + auto theta = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto x2 = paramFns[4].execute(record, arena).cast(); + auto y2 = paramFns[5].execute(record, arena).cast(); + auto theta2 = paramFns[6].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double x, double y, double theta, uint64_t ts, double x2, double y2, double theta2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* pose1 = pose_make_2d(x, y, theta, false, 0); + if (!pose1) return 0.0; + Temporal* inst = (Temporal*)tposeinst_make(pose1, (TimestampTz)ts); + free(pose1); + if (!inst) return 0.0; + Pose* pose2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!pose2) { free(inst); return 0.0; } + int r = always_eq_tpose_pose(inst, pose2); + free(inst); free(pose2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + x, y, theta, ts, x2, y2, theta2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTposePosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "AlwaysEqTposePosePhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTposePosePhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNePoseTposePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNePoseTposePhysicalFunction.cpp new file mode 100644 index 0000000000..c0e6643536 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNePoseTposePhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AlwaysNePoseTposePhysicalFunction::AlwaysNePoseTposePhysicalFunction(PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); +} + +VarVal AlwaysNePoseTposePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x2 = paramFns[0].execute(record, arena).cast(); + auto y2 = paramFns[1].execute(record, arena).cast(); + auto theta2 = paramFns[2].execute(record, arena).cast(); + auto x = paramFns[3].execute(record, arena).cast(); + auto y = paramFns[4].execute(record, arena).cast(); + auto theta = paramFns[5].execute(record, arena).cast(); + auto ts = paramFns[6].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double x2, double y2, double theta2, double x, double y, double theta, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* pose_s = pose_make_2d(x2, y2, theta2, false, 0); + if (!pose_s) return 0.0; + Pose* pose_t = pose_make_2d(x, y, theta, false, 0); + if (!pose_t) { free(pose_s); return 0.0; } + Temporal* inst = (Temporal*)tposeinst_make(pose_t, (TimestampTz)ts); + free(pose_t); + if (!inst) { free(pose_s); return 0.0; } + int r = always_ne_pose_tpose(pose_s, inst); + free(pose_s); free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + x2, y2, theta2, x, y, theta, ts); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNePoseTposePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "AlwaysNePoseTposePhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return AlwaysNePoseTposePhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTposePosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTposePosePhysicalFunction.cpp new file mode 100644 index 0000000000..3d0472a51d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTposePosePhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +AlwaysNeTposePosePhysicalFunction::AlwaysNeTposePosePhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); +} + +VarVal AlwaysNeTposePosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x = paramFns[0].execute(record, arena).cast(); + auto y = paramFns[1].execute(record, arena).cast(); + auto theta = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto x2 = paramFns[4].execute(record, arena).cast(); + auto y2 = paramFns[5].execute(record, arena).cast(); + auto theta2 = paramFns[6].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double x, double y, double theta, uint64_t ts, double x2, double y2, double theta2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* pose1 = pose_make_2d(x, y, theta, false, 0); + if (!pose1) return 0.0; + Temporal* inst = (Temporal*)tposeinst_make(pose1, (TimestampTz)ts); + free(pose1); + if (!inst) return 0.0; + Pose* pose2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!pose2) { free(inst); return 0.0; } + int r = always_ne_tpose_pose(inst, pose2); + free(inst); free(pose2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + x, y, theta, ts, x2, y2, theta2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTposePosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "AlwaysNeTposePosePhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTposePosePhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 71b501da60..bf02960bf3 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -394,6 +394,16 @@ add_plugin(AlwaysEqTnpointTnpoint PhysicalFunction nes-physical-operators Always add_plugin(EverNeTnpointTnpoint PhysicalFunction nes-physical-operators EverNeTnpointTnpointPhysicalFunction.cpp) add_plugin(AlwaysNeTnpointTnpoint PhysicalFunction nes-physical-operators AlwaysNeTnpointTnpointPhysicalFunction.cpp) add_plugin(NadTnpointTnpoint PhysicalFunction nes-physical-operators NadTnpointTnpointPhysicalFunction.cpp) +add_plugin(NadTposeGeo PhysicalFunction nes-physical-operators NadTposeGeoPhysicalFunction.cpp) +add_plugin(EverEqTposePose PhysicalFunction nes-physical-operators EverEqTposePosePhysicalFunction.cpp) +add_plugin(AlwaysEqTposePose PhysicalFunction nes-physical-operators AlwaysEqTposePosePhysicalFunction.cpp) +add_plugin(EverNeTposePose PhysicalFunction nes-physical-operators EverNeTposePosePhysicalFunction.cpp) +add_plugin(AlwaysNeTposePose PhysicalFunction nes-physical-operators AlwaysNeTposePosePhysicalFunction.cpp) +add_plugin(NadTposePose PhysicalFunction nes-physical-operators NadTposePosePhysicalFunction.cpp) +add_plugin(EverEqPoseTpose PhysicalFunction nes-physical-operators EverEqPoseTposePhysicalFunction.cpp) +add_plugin(AlwaysEqPoseTpose PhysicalFunction nes-physical-operators AlwaysEqPoseTposePhysicalFunction.cpp) +add_plugin(EverNePoseTpose PhysicalFunction nes-physical-operators EverNePoseTposePhysicalFunction.cpp) +add_plugin(AlwaysNePoseTpose PhysicalFunction nes-physical-operators AlwaysNePoseTposePhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EverEqPoseTposePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqPoseTposePhysicalFunction.cpp new file mode 100644 index 0000000000..4d2c2464a6 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqPoseTposePhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EverEqPoseTposePhysicalFunction::EverEqPoseTposePhysicalFunction(PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); +} + +VarVal EverEqPoseTposePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x2 = paramFns[0].execute(record, arena).cast(); + auto y2 = paramFns[1].execute(record, arena).cast(); + auto theta2 = paramFns[2].execute(record, arena).cast(); + auto x = paramFns[3].execute(record, arena).cast(); + auto y = paramFns[4].execute(record, arena).cast(); + auto theta = paramFns[5].execute(record, arena).cast(); + auto ts = paramFns[6].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double x2, double y2, double theta2, double x, double y, double theta, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* pose_s = pose_make_2d(x2, y2, theta2, false, 0); + if (!pose_s) return 0.0; + Pose* pose_t = pose_make_2d(x, y, theta, false, 0); + if (!pose_t) { free(pose_s); return 0.0; } + Temporal* inst = (Temporal*)tposeinst_make(pose_t, (TimestampTz)ts); + free(pose_t); + if (!inst) { free(pose_s); return 0.0; } + int r = ever_eq_pose_tpose(pose_s, inst); + free(pose_s); free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + x2, y2, theta2, x, y, theta, ts); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqPoseTposePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "EverEqPoseTposePhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return EverEqPoseTposePhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTposePosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTposePosePhysicalFunction.cpp new file mode 100644 index 0000000000..9fddd8a541 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTposePosePhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EverEqTposePosePhysicalFunction::EverEqTposePosePhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); +} + +VarVal EverEqTposePosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x = paramFns[0].execute(record, arena).cast(); + auto y = paramFns[1].execute(record, arena).cast(); + auto theta = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto x2 = paramFns[4].execute(record, arena).cast(); + auto y2 = paramFns[5].execute(record, arena).cast(); + auto theta2 = paramFns[6].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double x, double y, double theta, uint64_t ts, double x2, double y2, double theta2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* pose1 = pose_make_2d(x, y, theta, false, 0); + if (!pose1) return 0.0; + Temporal* inst = (Temporal*)tposeinst_make(pose1, (TimestampTz)ts); + free(pose1); + if (!inst) return 0.0; + Pose* pose2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!pose2) { free(inst); return 0.0; } + int r = ever_eq_tpose_pose(inst, pose2); + free(inst); free(pose2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + x, y, theta, ts, x2, y2, theta2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTposePosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "EverEqTposePosePhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return EverEqTposePosePhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNePoseTposePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNePoseTposePhysicalFunction.cpp new file mode 100644 index 0000000000..8aad773b72 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNePoseTposePhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EverNePoseTposePhysicalFunction::EverNePoseTposePhysicalFunction(PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); +} + +VarVal EverNePoseTposePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x2 = paramFns[0].execute(record, arena).cast(); + auto y2 = paramFns[1].execute(record, arena).cast(); + auto theta2 = paramFns[2].execute(record, arena).cast(); + auto x = paramFns[3].execute(record, arena).cast(); + auto y = paramFns[4].execute(record, arena).cast(); + auto theta = paramFns[5].execute(record, arena).cast(); + auto ts = paramFns[6].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double x2, double y2, double theta2, double x, double y, double theta, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* pose_s = pose_make_2d(x2, y2, theta2, false, 0); + if (!pose_s) return 0.0; + Pose* pose_t = pose_make_2d(x, y, theta, false, 0); + if (!pose_t) { free(pose_s); return 0.0; } + Temporal* inst = (Temporal*)tposeinst_make(pose_t, (TimestampTz)ts); + free(pose_t); + if (!inst) { free(pose_s); return 0.0; } + int r = ever_ne_pose_tpose(pose_s, inst); + free(pose_s); free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + x2, y2, theta2, x, y, theta, ts); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNePoseTposePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "EverNePoseTposePhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return EverNePoseTposePhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTposePosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTposePosePhysicalFunction.cpp new file mode 100644 index 0000000000..99f9def5be --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTposePosePhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EverNeTposePosePhysicalFunction::EverNeTposePosePhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); +} + +VarVal EverNeTposePosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x = paramFns[0].execute(record, arena).cast(); + auto y = paramFns[1].execute(record, arena).cast(); + auto theta = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto x2 = paramFns[4].execute(record, arena).cast(); + auto y2 = paramFns[5].execute(record, arena).cast(); + auto theta2 = paramFns[6].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double x, double y, double theta, uint64_t ts, double x2, double y2, double theta2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* pose1 = pose_make_2d(x, y, theta, false, 0); + if (!pose1) return 0.0; + Temporal* inst = (Temporal*)tposeinst_make(pose1, (TimestampTz)ts); + free(pose1); + if (!inst) return 0.0; + Pose* pose2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!pose2) { free(inst); return 0.0; } + int r = ever_ne_tpose_pose(inst, pose2); + free(inst); free(pose2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + x, y, theta, ts, x2, y2, theta2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTposePosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "EverNeTposePosePhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return EverNeTposePosePhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/NadTposeGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/NadTposeGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..30160666ae --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/NadTposeGeoPhysicalFunction.cpp @@ -0,0 +1,92 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +NadTposeGeoPhysicalFunction::NadTposeGeoPhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction wkt) +{ + paramFns.reserve(5); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(wkt)); +} + +VarVal NadTposeGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x = paramFns[0].execute(record, arena).cast(); + auto y = paramFns[1].execute(record, arena).cast(); + auto theta = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto wkt = paramFns[4].execute(record, arena); + const auto result = nautilus::invoke( + +[](double x, double y, double theta, uint64_t ts, const char* wkt, uint32_t wkt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* pose = pose_make_2d(x, y, theta, false, 0); + if (!pose) return 0.0; + Temporal* inst = (Temporal*)tposeinst_make(pose, (TimestampTz)ts); + free(pose); + if (!inst) return 0.0; + char* wkt_str = (char*)malloc(wkt_len + 1); + memcpy(wkt_str, wkt, wkt_len); + wkt_str[wkt_len] = '\0'; + GSERIALIZED* gs = geom_in(wkt_str, -1); + free(wkt_str); + if (!gs) { free(inst); return 0.0; } + double r = nad_tpose_geo(inst, gs); + free(inst); free(gs); + return r; + } catch (const std::exception&) { return 0.0; } + }, + x, y, theta, ts, wkt); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterNadTposeGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 5, + "NadTposeGeoPhysicalFunction requires 5 children but got {}", + arguments.childFunctions.size()); + return NadTposeGeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/NadTposePosePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/NadTposePosePhysicalFunction.cpp new file mode 100644 index 0000000000..fe253d9ed5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/NadTposePosePhysicalFunction.cpp @@ -0,0 +1,94 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +NadTposePosePhysicalFunction::NadTposePosePhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); +} + +VarVal NadTposePosePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x = paramFns[0].execute(record, arena).cast(); + auto y = paramFns[1].execute(record, arena).cast(); + auto theta = paramFns[2].execute(record, arena).cast(); + auto ts = paramFns[3].execute(record, arena).cast(); + auto x2 = paramFns[4].execute(record, arena).cast(); + auto y2 = paramFns[5].execute(record, arena).cast(); + auto theta2 = paramFns[6].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double x, double y, double theta, uint64_t ts, double x2, double y2, double theta2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* pose1 = pose_make_2d(x, y, theta, false, 0); + if (!pose1) return 0.0; + Temporal* inst = (Temporal*)tposeinst_make(pose1, (TimestampTz)ts); + free(pose1); + if (!inst) return 0.0; + Pose* pose2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!pose2) { free(inst); return 0.0; } + double r = nad_tpose_pose(inst, pose2); + free(inst); free(pose2); + return r; + } catch (const std::exception&) { return 0.0; } + }, + x, y, theta, ts, x2, y2, theta2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterNadTposePosePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "NadTposePosePhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return NadTposePosePhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index e7d8aabfd5..a5106a3fc7 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -865,6 +865,16 @@ ALWAYS_EQ_TNPOINT_TNPOINT: 'ALWAYS_EQ_TNPOINT_TNPOINT' | 'always_eq_tnpoint_tnpo EVER_NE_TNPOINT_TNPOINT: 'EVER_NE_TNPOINT_TNPOINT' | 'ever_ne_tnpoint_tnpoint'; ALWAYS_NE_TNPOINT_TNPOINT: 'ALWAYS_NE_TNPOINT_TNPOINT' | 'always_ne_tnpoint_tnpoint'; NAD_TNPOINT_TNPOINT: 'NAD_TNPOINT_TNPOINT' | 'nad_tnpoint_tnpoint'; +NAD_TPOSE_GEO: 'NAD_TPOSE_GEO' | 'nad_tpose_geo'; +EVER_EQ_TPOSE_POSE: 'EVER_EQ_TPOSE_POSE' | 'ever_eq_tpose_pose'; +ALWAYS_EQ_TPOSE_POSE: 'ALWAYS_EQ_TPOSE_POSE' | 'always_eq_tpose_pose'; +EVER_NE_TPOSE_POSE: 'EVER_NE_TPOSE_POSE' | 'ever_ne_tpose_pose'; +ALWAYS_NE_TPOSE_POSE: 'ALWAYS_NE_TPOSE_POSE' | 'always_ne_tpose_pose'; +NAD_TPOSE_POSE: 'NAD_TPOSE_POSE' | 'nad_tpose_pose'; +EVER_EQ_POSE_TPOSE: 'EVER_EQ_POSE_TPOSE' | 'ever_eq_pose_tpose'; +ALWAYS_EQ_POSE_TPOSE: 'ALWAYS_EQ_POSE_TPOSE' | 'always_eq_pose_tpose'; +EVER_NE_POSE_TPOSE: 'EVER_NE_POSE_TPOSE' | 'ever_ne_pose_tpose'; +ALWAYS_NE_POSE_TPOSE: 'ALWAYS_NE_POSE_TPOSE' | 'always_ne_pose_tpose'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 94f98122e2..3ef07fe59e 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -446,6 +446,16 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -10132,6 +10142,144 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(NadTnpointTnpointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); } /* END CODEGEN PARSER GLUE: NAD_TNPOINT_TNPOINT */ + case AntlrSQLParser::NAD_TPOSE_GEO: { + PRECONDITION(ctx->functionParam().size() == 5, + "NadTposeGeo requires 5 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + return LogicalFunction(NadTposeGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4))); + } + /* END CODEGEN PARSER GLUE: NAD_TPOSE_GEO */ + case AntlrSQLParser::EVER_EQ_TPOSE_POSE: { + PRECONDITION(ctx->functionParam().size() == 7, + "EverEqTposePose requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(EverEqTposePoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_TPOSE_POSE */ + case AntlrSQLParser::ALWAYS_EQ_TPOSE_POSE: { + PRECONDITION(ctx->functionParam().size() == 7, + "AlwaysEqTposePose requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(AlwaysEqTposePoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TPOSE_POSE */ + case AntlrSQLParser::EVER_NE_TPOSE_POSE: { + PRECONDITION(ctx->functionParam().size() == 7, + "EverNeTposePose requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(EverNeTposePoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_TPOSE_POSE */ + case AntlrSQLParser::ALWAYS_NE_TPOSE_POSE: { + PRECONDITION(ctx->functionParam().size() == 7, + "AlwaysNeTposePose requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(AlwaysNeTposePoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TPOSE_POSE */ + case AntlrSQLParser::NAD_TPOSE_POSE: { + PRECONDITION(ctx->functionParam().size() == 7, + "NadTposePose requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(NadTposePoseLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: NAD_TPOSE_POSE */ + case AntlrSQLParser::EVER_EQ_POSE_TPOSE: { + PRECONDITION(ctx->functionParam().size() == 7, + "EverEqPoseTpose requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(EverEqPoseTposeLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_POSE_TPOSE */ + case AntlrSQLParser::ALWAYS_EQ_POSE_TPOSE: { + PRECONDITION(ctx->functionParam().size() == 7, + "AlwaysEqPoseTpose requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(AlwaysEqPoseTposeLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_POSE_TPOSE */ + case AntlrSQLParser::EVER_NE_POSE_TPOSE: { + PRECONDITION(ctx->functionParam().size() == 7, + "EverNePoseTpose requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(EverNePoseTposeLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_POSE_TPOSE */ + case AntlrSQLParser::ALWAYS_NE_POSE_TPOSE: { + PRECONDITION(ctx->functionParam().size() == 7, + "AlwaysNePoseTpose requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(AlwaysNePoseTposeLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_POSE_TPOSE */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From d416e5e9f14b83ba1cb0a0fe66b711209af2130d Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 08:57:58 +0200 Subject: [PATCH 69/86] feat(meos): add tpose_tpose 2D per-event scalar operators (W121) Wires five tpose-vs-tpose operators using an 8-arg all-numeric pattern (x1:FLOAT64, y1:FLOAT64, theta1:FLOAT64, ts1:UINT64, x2:FLOAT64, y2:FLOAT64, theta2:FLOAT64, ts2:UINT64) -> FLOAT64. Each physical function builds two 2D tpose instants via pose_make_2d(x,y,theta,false,0) and tposeinst_make. Operators: EVER_EQ/ALWAYS_EQ/EVER_NE/ALWAYS_NE _TPOSE_TPOSE (return 0.0/1.0) and NAD_TPOSE_TPOSE (nearest approach distance or -1.0 on error). --- .../AlwaysEqTposeTposeLogicalFunction.hpp | 54 ++++++++ .../AlwaysNeTposeTposeLogicalFunction.hpp | 54 ++++++++ .../Meos/EverEqTposeTposeLogicalFunction.hpp | 54 ++++++++ .../Meos/EverNeTposeTposeLogicalFunction.hpp | 54 ++++++++ .../Meos/NadTposeTposeLogicalFunction.hpp | 54 ++++++++ .../AlwaysEqTposeTposeLogicalFunction.cpp | 118 ++++++++++++++++++ .../AlwaysNeTposeTposeLogicalFunction.cpp | 118 ++++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../Meos/EverEqTposeTposeLogicalFunction.cpp | 118 ++++++++++++++++++ .../Meos/EverNeTposeTposeLogicalFunction.cpp | 118 ++++++++++++++++++ .../Meos/NadTposeTposeLogicalFunction.cpp | 118 ++++++++++++++++++ .../AlwaysEqTposeTposePhysicalFunction.hpp | 35 ++++++ .../AlwaysNeTposeTposePhysicalFunction.hpp | 35 ++++++ .../Meos/EverEqTposeTposePhysicalFunction.hpp | 35 ++++++ .../Meos/EverNeTposeTposePhysicalFunction.hpp | 35 ++++++ .../Meos/NadTposeTposePhysicalFunction.hpp | 35 ++++++ .../AlwaysEqTposeTposePhysicalFunction.cpp | 102 +++++++++++++++ .../AlwaysNeTposeTposePhysicalFunction.cpp | 102 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + .../Meos/EverEqTposeTposePhysicalFunction.cpp | 102 +++++++++++++++ .../Meos/EverNeTposeTposePhysicalFunction.cpp | 102 +++++++++++++++ .../Meos/NadTposeTposePhysicalFunction.cpp | 102 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 7 +- .../src/AntlrSQLQueryPlanCreator.cpp | 80 ++++++++++++ 24 files changed, 1641 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTposeTposeLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTposeTposeLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTposeTposeLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTposeTposeLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/NadTposeTposeLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTposeTposeLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTposeTposeLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTposeTposeLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTposeTposeLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/NadTposeTposeLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTposeTposePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTposeTposePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTposeTposePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTposeTposePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/NadTposeTposePhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTposeTposePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTposeTposePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTposeTposePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTposeTposePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/NadTposeTposePhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTposeTposeLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTposeTposeLogicalFunction.hpp new file mode 100644 index 0000000000..815e30386c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTposeTposeLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two 2D tpose instants are always equal, 0.0 otherwise. + * + * Args: (x1:FLOAT64, y1:FLOAT64, theta1:FLOAT64, ts1:UINT64, + * x2:FLOAT64, y2:FLOAT64, theta2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class AlwaysEqTposeTposeLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTposeTpose"; + + AlwaysEqTposeTposeLogicalFunction(LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, + LogicalFunction ts1, + LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTposeTposeLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTposeTposeLogicalFunction.hpp new file mode 100644 index 0000000000..17975a44dc --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTposeTposeLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two 2D tpose instants are always not equal, 0.0 otherwise. + * + * Args: (x1:FLOAT64, y1:FLOAT64, theta1:FLOAT64, ts1:UINT64, + * x2:FLOAT64, y2:FLOAT64, theta2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class AlwaysNeTposeTposeLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTposeTpose"; + + AlwaysNeTposeTposeLogicalFunction(LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, + LogicalFunction ts1, + LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTposeTposeLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTposeTposeLogicalFunction.hpp new file mode 100644 index 0000000000..5942a053fe --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTposeTposeLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two 2D tpose instants are ever equal, 0.0 otherwise. + * + * Args: (x1:FLOAT64, y1:FLOAT64, theta1:FLOAT64, ts1:UINT64, + * x2:FLOAT64, y2:FLOAT64, theta2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class EverEqTposeTposeLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTposeTpose"; + + EverEqTposeTposeLogicalFunction(LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, + LogicalFunction ts1, + LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTposeTposeLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTposeTposeLogicalFunction.hpp new file mode 100644 index 0000000000..3a7388923b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTposeTposeLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two 2D tpose instants are ever not equal, 0.0 otherwise. + * + * Args: (x1:FLOAT64, y1:FLOAT64, theta1:FLOAT64, ts1:UINT64, + * x2:FLOAT64, y2:FLOAT64, theta2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class EverNeTposeTposeLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTposeTpose"; + + EverNeTposeTposeLogicalFunction(LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, + LogicalFunction ts1, + LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/NadTposeTposeLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/NadTposeTposeLogicalFunction.hpp new file mode 100644 index 0000000000..3d09da1b7b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/NadTposeTposeLogicalFunction.hpp @@ -0,0 +1,54 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nearest approach distance between two 2D tpose instants. + * + * Args: (x1:FLOAT64, y1:FLOAT64, theta1:FLOAT64, ts1:UINT64, + * x2:FLOAT64, y2:FLOAT64, theta2:FLOAT64, ts2:UINT64) -> FLOAT64. + */ +class NadTposeTposeLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "NadTposeTpose"; + + NadTposeTposeLogicalFunction(LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, + LogicalFunction ts1, + LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, + LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTposeTposeLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTposeTposeLogicalFunction.cpp new file mode 100644 index 0000000000..f3276aa7c8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTposeTposeLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTposeTposeLogicalFunction::AlwaysEqTposeTposeLogicalFunction( + LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, + LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(x1)); + parameters.push_back(std::move(y1)); + parameters.push_back(std::move(theta1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(ts2)); +} + +DataType AlwaysEqTposeTposeLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTposeTposeLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTposeTposeLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTposeTposeLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "AlwaysEqTposeTposeLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTposeTposeLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTposeTposeLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTposeTposeLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqTposeTposeLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysEqTposeTposeLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTposeTposeLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "AlwaysEqTposeTposeLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return AlwaysEqTposeTposeLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTposeTposeLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTposeTposeLogicalFunction.cpp new file mode 100644 index 0000000000..8990844640 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTposeTposeLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTposeTposeLogicalFunction::AlwaysNeTposeTposeLogicalFunction( + LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, + LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(x1)); + parameters.push_back(std::move(y1)); + parameters.push_back(std::move(theta1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(ts2)); +} + +DataType AlwaysNeTposeTposeLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTposeTposeLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTposeTposeLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTposeTposeLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "AlwaysNeTposeTposeLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTposeTposeLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTposeTposeLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTposeTposeLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeTposeTposeLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysNeTposeTposeLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTposeTposeLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "AlwaysNeTposeTposeLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return AlwaysNeTposeTposeLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index ac864b86b8..e992c8d631 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -405,6 +405,11 @@ add_plugin(EverEqPoseTpose LogicalFunction nes-logical-operators EverEqPoseTpose add_plugin(AlwaysEqPoseTpose LogicalFunction nes-logical-operators AlwaysEqPoseTposeLogicalFunction.cpp) add_plugin(EverNePoseTpose LogicalFunction nes-logical-operators EverNePoseTposeLogicalFunction.cpp) add_plugin(AlwaysNePoseTpose LogicalFunction nes-logical-operators AlwaysNePoseTposeLogicalFunction.cpp) +add_plugin(EverEqTposeTpose LogicalFunction nes-logical-operators EverEqTposeTposeLogicalFunction.cpp) +add_plugin(AlwaysEqTposeTpose LogicalFunction nes-logical-operators AlwaysEqTposeTposeLogicalFunction.cpp) +add_plugin(EverNeTposeTpose LogicalFunction nes-logical-operators EverNeTposeTposeLogicalFunction.cpp) +add_plugin(AlwaysNeTposeTpose LogicalFunction nes-logical-operators AlwaysNeTposeTposeLogicalFunction.cpp) +add_plugin(NadTposeTpose LogicalFunction nes-logical-operators NadTposeTposeLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTposeTposeLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTposeTposeLogicalFunction.cpp new file mode 100644 index 0000000000..cb9c20bc8c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTposeTposeLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTposeTposeLogicalFunction::EverEqTposeTposeLogicalFunction( + LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, + LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(x1)); + parameters.push_back(std::move(y1)); + parameters.push_back(std::move(theta1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(ts2)); +} + +DataType EverEqTposeTposeLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTposeTposeLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTposeTposeLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTposeTposeLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "EverEqTposeTposeLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTposeTposeLogicalFunction::getType() const { return NAME; } + +bool EverEqTposeTposeLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTposeTposeLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqTposeTposeLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverEqTposeTposeLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTposeTposeLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "EverEqTposeTposeLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return EverEqTposeTposeLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTposeTposeLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTposeTposeLogicalFunction.cpp new file mode 100644 index 0000000000..0dfd61bc1a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTposeTposeLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTposeTposeLogicalFunction::EverNeTposeTposeLogicalFunction( + LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, + LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(x1)); + parameters.push_back(std::move(y1)); + parameters.push_back(std::move(theta1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(ts2)); +} + +DataType EverNeTposeTposeLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTposeTposeLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTposeTposeLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTposeTposeLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "EverNeTposeTposeLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTposeTposeLogicalFunction::getType() const { return NAME; } + +bool EverNeTposeTposeLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTposeTposeLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeTposeTposeLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverNeTposeTposeLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTposeTposeLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "EverNeTposeTposeLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return EverNeTposeTposeLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/NadTposeTposeLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/NadTposeTposeLogicalFunction.cpp new file mode 100644 index 0000000000..e311b3d71f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/NadTposeTposeLogicalFunction.cpp @@ -0,0 +1,118 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +NadTposeTposeLogicalFunction::NadTposeTposeLogicalFunction( + LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, + LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(8); + parameters.push_back(std::move(x1)); + parameters.push_back(std::move(y1)); + parameters.push_back(std::move(theta1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(ts2)); +} + +DataType NadTposeTposeLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction NadTposeTposeLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector NadTposeTposeLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction NadTposeTposeLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 8, + "NadTposeTposeLogicalFunction requires 8 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view NadTposeTposeLogicalFunction::getType() const { return NAME; } + +bool NadTposeTposeLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string NadTposeTposeLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction NadTposeTposeLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(8); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "x1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "y1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "theta1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction NadTposeTposeLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterNadTposeTposeLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 8, + "NadTposeTposeLogicalFunction requires 8 children but got {}", + arguments.children.size()); + return NadTposeTposeLogicalFunction(std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTposeTposePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTposeTposePhysicalFunction.hpp new file mode 100644 index 0000000000..16cfd9d3d2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTposeTposePhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTposeTposePhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTposeTposePhysicalFunction(PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, + PhysicalFunction ts1, + PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, + PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTposeTposePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTposeTposePhysicalFunction.hpp new file mode 100644 index 0000000000..b31cf86f60 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTposeTposePhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTposeTposePhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTposeTposePhysicalFunction(PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, + PhysicalFunction ts1, + PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, + PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTposeTposePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTposeTposePhysicalFunction.hpp new file mode 100644 index 0000000000..56abe9061c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTposeTposePhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTposeTposePhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTposeTposePhysicalFunction(PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, + PhysicalFunction ts1, + PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, + PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTposeTposePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTposeTposePhysicalFunction.hpp new file mode 100644 index 0000000000..06e0615b1b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTposeTposePhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTposeTposePhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTposeTposePhysicalFunction(PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, + PhysicalFunction ts1, + PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, + PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/NadTposeTposePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/NadTposeTposePhysicalFunction.hpp new file mode 100644 index 0000000000..b5f2e25824 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/NadTposeTposePhysicalFunction.hpp @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class NadTposeTposePhysicalFunction : public PhysicalFunctionConcept { +public: + NadTposeTposePhysicalFunction(PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, + PhysicalFunction ts1, + PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, + PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTposeTposePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTposeTposePhysicalFunction.cpp new file mode 100644 index 0000000000..18dd6ab81e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTposeTposePhysicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTposeTposePhysicalFunction::AlwaysEqTposeTposePhysicalFunction( + PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, + PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(x1)); + paramFns.push_back(std::move(y1)); + paramFns.push_back(std::move(theta1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AlwaysEqTposeTposePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x1 = paramFns[0].execute(record, arena).cast(); + auto y1 = paramFns[1].execute(record, arena).cast(); + auto theta1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto x2 = paramFns[4].execute(record, arena).cast(); + auto y2 = paramFns[5].execute(record, arena).cast(); + auto theta2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double x1, double y1, double theta1, uint64_t ts1, + double x2, double y2, double theta2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* p1 = pose_make_2d(x1, y1, theta1, false, 0); + if (!p1) return 0.0; + Temporal* inst1 = (Temporal*)tposeinst_make(p1, (TimestampTz)ts1); + free(p1); + if (!inst1) return 0.0; + Pose* p2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!p2) { free(inst1); return 0.0; } + Temporal* inst2 = (Temporal*)tposeinst_make(p2, (TimestampTz)ts2); + free(p2); + if (!inst2) { free(inst1); return 0.0; } + int r = always_eq_tpose_tpose(inst1, inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + x1, y1, theta1, ts1, x2, y2, theta2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTposeTposePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "AlwaysEqTposeTposePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTposeTposePhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTposeTposePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTposeTposePhysicalFunction.cpp new file mode 100644 index 0000000000..5f716ed3ed --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTposeTposePhysicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTposeTposePhysicalFunction::AlwaysNeTposeTposePhysicalFunction( + PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, + PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(x1)); + paramFns.push_back(std::move(y1)); + paramFns.push_back(std::move(theta1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AlwaysNeTposeTposePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x1 = paramFns[0].execute(record, arena).cast(); + auto y1 = paramFns[1].execute(record, arena).cast(); + auto theta1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto x2 = paramFns[4].execute(record, arena).cast(); + auto y2 = paramFns[5].execute(record, arena).cast(); + auto theta2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double x1, double y1, double theta1, uint64_t ts1, + double x2, double y2, double theta2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* p1 = pose_make_2d(x1, y1, theta1, false, 0); + if (!p1) return 0.0; + Temporal* inst1 = (Temporal*)tposeinst_make(p1, (TimestampTz)ts1); + free(p1); + if (!inst1) return 0.0; + Pose* p2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!p2) { free(inst1); return 0.0; } + Temporal* inst2 = (Temporal*)tposeinst_make(p2, (TimestampTz)ts2); + free(p2); + if (!inst2) { free(inst1); return 0.0; } + int r = always_ne_tpose_tpose(inst1, inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + x1, y1, theta1, ts1, x2, y2, theta2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTposeTposePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "AlwaysNeTposeTposePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTposeTposePhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index bf02960bf3..cd5a4e12d5 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -404,6 +404,11 @@ add_plugin(EverEqPoseTpose PhysicalFunction nes-physical-operators EverEqPoseTpo add_plugin(AlwaysEqPoseTpose PhysicalFunction nes-physical-operators AlwaysEqPoseTposePhysicalFunction.cpp) add_plugin(EverNePoseTpose PhysicalFunction nes-physical-operators EverNePoseTposePhysicalFunction.cpp) add_plugin(AlwaysNePoseTpose PhysicalFunction nes-physical-operators AlwaysNePoseTposePhysicalFunction.cpp) +add_plugin(EverEqTposeTpose PhysicalFunction nes-physical-operators EverEqTposeTposePhysicalFunction.cpp) +add_plugin(AlwaysEqTposeTpose PhysicalFunction nes-physical-operators AlwaysEqTposeTposePhysicalFunction.cpp) +add_plugin(EverNeTposeTpose PhysicalFunction nes-physical-operators EverNeTposeTposePhysicalFunction.cpp) +add_plugin(AlwaysNeTposeTpose PhysicalFunction nes-physical-operators AlwaysNeTposeTposePhysicalFunction.cpp) +add_plugin(NadTposeTpose PhysicalFunction nes-physical-operators NadTposeTposePhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTposeTposePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTposeTposePhysicalFunction.cpp new file mode 100644 index 0000000000..cb888a09a3 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTposeTposePhysicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTposeTposePhysicalFunction::EverEqTposeTposePhysicalFunction( + PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, + PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(x1)); + paramFns.push_back(std::move(y1)); + paramFns.push_back(std::move(theta1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EverEqTposeTposePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x1 = paramFns[0].execute(record, arena).cast(); + auto y1 = paramFns[1].execute(record, arena).cast(); + auto theta1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto x2 = paramFns[4].execute(record, arena).cast(); + auto y2 = paramFns[5].execute(record, arena).cast(); + auto theta2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double x1, double y1, double theta1, uint64_t ts1, + double x2, double y2, double theta2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* p1 = pose_make_2d(x1, y1, theta1, false, 0); + if (!p1) return 0.0; + Temporal* inst1 = (Temporal*)tposeinst_make(p1, (TimestampTz)ts1); + free(p1); + if (!inst1) return 0.0; + Pose* p2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!p2) { free(inst1); return 0.0; } + Temporal* inst2 = (Temporal*)tposeinst_make(p2, (TimestampTz)ts2); + free(p2); + if (!inst2) { free(inst1); return 0.0; } + int r = ever_eq_tpose_tpose(inst1, inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + x1, y1, theta1, ts1, x2, y2, theta2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTposeTposePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "EverEqTposeTposePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return EverEqTposeTposePhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTposeTposePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTposeTposePhysicalFunction.cpp new file mode 100644 index 0000000000..2433995d0e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTposeTposePhysicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTposeTposePhysicalFunction::EverNeTposeTposePhysicalFunction( + PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, + PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(x1)); + paramFns.push_back(std::move(y1)); + paramFns.push_back(std::move(theta1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EverNeTposeTposePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x1 = paramFns[0].execute(record, arena).cast(); + auto y1 = paramFns[1].execute(record, arena).cast(); + auto theta1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto x2 = paramFns[4].execute(record, arena).cast(); + auto y2 = paramFns[5].execute(record, arena).cast(); + auto theta2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double x1, double y1, double theta1, uint64_t ts1, + double x2, double y2, double theta2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* p1 = pose_make_2d(x1, y1, theta1, false, 0); + if (!p1) return 0.0; + Temporal* inst1 = (Temporal*)tposeinst_make(p1, (TimestampTz)ts1); + free(p1); + if (!inst1) return 0.0; + Pose* p2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!p2) { free(inst1); return 0.0; } + Temporal* inst2 = (Temporal*)tposeinst_make(p2, (TimestampTz)ts2); + free(p2); + if (!inst2) { free(inst1); return 0.0; } + int r = ever_ne_tpose_tpose(inst1, inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + x1, y1, theta1, ts1, x2, y2, theta2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTposeTposePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "EverNeTposeTposePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return EverNeTposeTposePhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/NadTposeTposePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/NadTposeTposePhysicalFunction.cpp new file mode 100644 index 0000000000..57f3232df9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/NadTposeTposePhysicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +NadTposeTposePhysicalFunction::NadTposeTposePhysicalFunction( + PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, + PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2) +{ + paramFns.reserve(8); + paramFns.push_back(std::move(x1)); + paramFns.push_back(std::move(y1)); + paramFns.push_back(std::move(theta1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal NadTposeTposePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x1 = paramFns[0].execute(record, arena).cast(); + auto y1 = paramFns[1].execute(record, arena).cast(); + auto theta1 = paramFns[2].execute(record, arena).cast(); + auto ts1 = paramFns[3].execute(record, arena).cast(); + auto x2 = paramFns[4].execute(record, arena).cast(); + auto y2 = paramFns[5].execute(record, arena).cast(); + auto theta2 = paramFns[6].execute(record, arena).cast(); + auto ts2 = paramFns[7].execute(record, arena).cast(); + + const auto result = nautilus::invoke( + +[](double x1, double y1, double theta1, uint64_t ts1, + double x2, double y2, double theta2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + Pose* p1 = pose_make_2d(x1, y1, theta1, false, 0); + if (!p1) return 0.0; + Temporal* inst1 = (Temporal*)tposeinst_make(p1, (TimestampTz)ts1); + free(p1); + if (!inst1) return 0.0; + Pose* p2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!p2) { free(inst1); return 0.0; } + Temporal* inst2 = (Temporal*)tposeinst_make(p2, (TimestampTz)ts2); + free(p2); + if (!inst2) { free(inst1); return 0.0; } + double r = nad_tpose_tpose(inst1, inst2); + free(inst1); free(inst2); + return r; + } catch (const std::exception&) { return -1.0; } + }, + x1, y1, theta1, ts1, x2, y2, theta2, ts2); + + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterNadTposeTposePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 8, + "NadTposeTposePhysicalFunction requires 8 children but got {}", + arguments.childFunctions.size()); + return NadTposeTposePhysicalFunction(std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index a5106a3fc7..921fdee9c3 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -875,6 +875,11 @@ EVER_EQ_POSE_TPOSE: 'EVER_EQ_POSE_TPOSE' | 'ever_eq_pose_tpose'; ALWAYS_EQ_POSE_TPOSE: 'ALWAYS_EQ_POSE_TPOSE' | 'always_eq_pose_tpose'; EVER_NE_POSE_TPOSE: 'EVER_NE_POSE_TPOSE' | 'ever_ne_pose_tpose'; ALWAYS_NE_POSE_TPOSE: 'ALWAYS_NE_POSE_TPOSE' | 'always_ne_pose_tpose'; +EVER_EQ_TPOSE_TPOSE: 'EVER_EQ_TPOSE_TPOSE' | 'ever_eq_tpose_tpose'; +ALWAYS_EQ_TPOSE_TPOSE: 'ALWAYS_EQ_TPOSE_TPOSE' | 'always_eq_tpose_tpose'; +EVER_NE_TPOSE_TPOSE: 'EVER_NE_TPOSE_TPOSE' | 'ever_ne_tpose_tpose'; +ALWAYS_NE_TPOSE_TPOSE: 'ALWAYS_NE_TPOSE_TPOSE' | 'always_ne_tpose_tpose'; +NAD_TPOSE_TPOSE: 'NAD_TPOSE_TPOSE' | 'nad_tpose_tpose'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 3ef07fe59e..c00cd35b42 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -456,6 +456,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -10280,6 +10285,81 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(AlwaysNePoseTposeLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); } /* END CODEGEN PARSER GLUE: ALWAYS_NE_POSE_TPOSE */ + case AntlrSQLParser::EVER_EQ_TPOSE_TPOSE: { + PRECONDITION(ctx->functionParam().size() == 8, + "EverEqTposeTpose requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(EverEqTposeTposeLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_TPOSE_TPOSE */ + case AntlrSQLParser::ALWAYS_EQ_TPOSE_TPOSE: { + PRECONDITION(ctx->functionParam().size() == 8, + "AlwaysEqTposeTpose requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(AlwaysEqTposeTposeLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TPOSE_TPOSE */ + case AntlrSQLParser::EVER_NE_TPOSE_TPOSE: { + PRECONDITION(ctx->functionParam().size() == 8, + "EverNeTposeTpose requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(EverNeTposeTposeLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_TPOSE_TPOSE */ + case AntlrSQLParser::ALWAYS_NE_TPOSE_TPOSE: { + PRECONDITION(ctx->functionParam().size() == 8, + "AlwaysNeTposeTpose requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(AlwaysNeTposeTposeLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TPOSE_TPOSE */ + case AntlrSQLParser::NAD_TPOSE_TPOSE: { + PRECONDITION(ctx->functionParam().size() == 8, + "NadTposeTpose requires 8 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + return LogicalFunction(NadTposeTposeLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); + } + /* END CODEGEN PARSER GLUE: NAD_TPOSE_TPOSE */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From a317eb3144829922d3253fe14d518bfaba4a65a2 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 10:19:30 +0200 Subject: [PATCH 70/86] feat(meos): add trgeometry 2D per-event scalar operators for geo (W122) Wires nine trgeometry operators using a dual-VARCHAR pattern. A trgeometry 2D instant is built from (ref_wkt:VARCHAR, x:FLOAT64, y:FLOAT64, theta:FLOAT64, ts:UINT64) via geom_in(ref_wkt), pose_make_2d(x,y,theta,false,0), and trgeoinst_make(gs_ref, pose, ts). Pattern A (6-arg trgeometry-first with trailing target VARCHAR): EVER_EQ/ALWAYS_EQ/EVER_NE/ALWAYS_NE/NAD _TRGEOMETRY_GEO. Pattern B (6-arg geo-first reversed, target VARCHAR first): EVER_EQ/ALWAYS_EQ/EVER_NE/ALWAYS_NE_GEO_TRGEOMETRY. --- .../AlwaysEqGeoTrgeometryLogicalFunction.hpp | 48 +++++++ .../AlwaysEqTrgeometryGeoLogicalFunction.hpp | 48 +++++++ .../AlwaysNeGeoTrgeometryLogicalFunction.hpp | 48 +++++++ .../AlwaysNeTrgeometryGeoLogicalFunction.hpp | 48 +++++++ .../EverEqGeoTrgeometryLogicalFunction.hpp | 48 +++++++ .../EverEqTrgeometryGeoLogicalFunction.hpp | 48 +++++++ .../EverNeGeoTrgeometryLogicalFunction.hpp | 48 +++++++ .../EverNeTrgeometryGeoLogicalFunction.hpp | 48 +++++++ .../Meos/NadTrgeometryGeoLogicalFunction.hpp | 48 +++++++ .../AlwaysEqGeoTrgeometryLogicalFunction.cpp | 111 +++++++++++++++ .../AlwaysEqTrgeometryGeoLogicalFunction.cpp | 111 +++++++++++++++ .../AlwaysNeGeoTrgeometryLogicalFunction.cpp | 111 +++++++++++++++ .../AlwaysNeTrgeometryGeoLogicalFunction.cpp | 111 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 9 ++ .../EverEqGeoTrgeometryLogicalFunction.cpp | 111 +++++++++++++++ .../EverEqTrgeometryGeoLogicalFunction.cpp | 111 +++++++++++++++ .../EverNeGeoTrgeometryLogicalFunction.cpp | 111 +++++++++++++++ .../EverNeTrgeometryGeoLogicalFunction.cpp | 111 +++++++++++++++ .../Meos/NadTrgeometryGeoLogicalFunction.cpp | 111 +++++++++++++++ .../AlwaysEqGeoTrgeometryPhysicalFunction.hpp | 32 +++++ .../AlwaysEqTrgeometryGeoPhysicalFunction.hpp | 32 +++++ .../AlwaysNeGeoTrgeometryPhysicalFunction.hpp | 32 +++++ .../AlwaysNeTrgeometryGeoPhysicalFunction.hpp | 32 +++++ .../EverEqGeoTrgeometryPhysicalFunction.hpp | 32 +++++ .../EverEqTrgeometryGeoPhysicalFunction.hpp | 32 +++++ .../EverNeGeoTrgeometryPhysicalFunction.hpp | 32 +++++ .../EverNeTrgeometryGeoPhysicalFunction.hpp | 32 +++++ .../Meos/NadTrgeometryGeoPhysicalFunction.hpp | 32 +++++ .../AlwaysEqGeoTrgeometryPhysicalFunction.cpp | 98 ++++++++++++++ .../AlwaysEqTrgeometryGeoPhysicalFunction.cpp | 98 ++++++++++++++ .../AlwaysNeGeoTrgeometryPhysicalFunction.cpp | 98 ++++++++++++++ .../AlwaysNeTrgeometryGeoPhysicalFunction.cpp | 98 ++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 9 ++ .../EverEqGeoTrgeometryPhysicalFunction.cpp | 98 ++++++++++++++ .../EverEqTrgeometryGeoPhysicalFunction.cpp | 98 ++++++++++++++ .../EverNeGeoTrgeometryPhysicalFunction.cpp | 98 ++++++++++++++ .../EverNeTrgeometryGeoPhysicalFunction.cpp | 98 ++++++++++++++ .../Meos/NadTrgeometryGeoPhysicalFunction.cpp | 98 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 11 +- .../src/AntlrSQLQueryPlanCreator.cpp | 126 ++++++++++++++++++ 40 files changed, 2755 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqGeoTrgeometryLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTrgeometryGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeGeoTrgeometryLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTrgeometryGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqGeoTrgeometryLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTrgeometryGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeGeoTrgeometryLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTrgeometryGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/NadTrgeometryGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqGeoTrgeometryLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTrgeometryGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeGeoTrgeometryLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTrgeometryGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqGeoTrgeometryLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTrgeometryGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeGeoTrgeometryLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTrgeometryGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/NadTrgeometryGeoLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqGeoTrgeometryPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTrgeometryGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeGeoTrgeometryPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTrgeometryGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqGeoTrgeometryPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTrgeometryGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeGeoTrgeometryPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTrgeometryGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/NadTrgeometryGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqGeoTrgeometryPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTrgeometryGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeGeoTrgeometryPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTrgeometryGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqGeoTrgeometryPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTrgeometryGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeGeoTrgeometryPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTrgeometryGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/NadTrgeometryGeoPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqGeoTrgeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqGeoTrgeometryLogicalFunction.hpp new file mode 100644 index 0000000000..6ba9cb98d1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqGeoTrgeometryLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the static geometry is always equal to the 2D trgeometry instant. + */ +class AlwaysEqGeoTrgeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqGeoTrgeometry"; + + AlwaysEqGeoTrgeometryLogicalFunction(LogicalFunction tgt_wkt, LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTrgeometryGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTrgeometryGeoLogicalFunction.hpp new file mode 100644 index 0000000000..54cf4ac351 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTrgeometryGeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the 2D trgeometry instant is always equal to the static geometry. + */ +class AlwaysEqTrgeometryGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTrgeometryGeo"; + + AlwaysEqTrgeometryGeoLogicalFunction(LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction tgt_wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeGeoTrgeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeGeoTrgeometryLogicalFunction.hpp new file mode 100644 index 0000000000..a2e6f94997 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeGeoTrgeometryLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the static geometry is always not equal to the 2D trgeometry instant. + */ +class AlwaysNeGeoTrgeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeGeoTrgeometry"; + + AlwaysNeGeoTrgeometryLogicalFunction(LogicalFunction tgt_wkt, LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTrgeometryGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTrgeometryGeoLogicalFunction.hpp new file mode 100644 index 0000000000..ede9a4ef9f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTrgeometryGeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the 2D trgeometry instant is always not equal to the static geometry. + */ +class AlwaysNeTrgeometryGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTrgeometryGeo"; + + AlwaysNeTrgeometryGeoLogicalFunction(LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction tgt_wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqGeoTrgeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqGeoTrgeometryLogicalFunction.hpp new file mode 100644 index 0000000000..5a49a6f0f8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqGeoTrgeometryLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the static geometry is ever equal to the 2D trgeometry instant. + */ +class EverEqGeoTrgeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqGeoTrgeometry"; + + EverEqGeoTrgeometryLogicalFunction(LogicalFunction tgt_wkt, LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTrgeometryGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTrgeometryGeoLogicalFunction.hpp new file mode 100644 index 0000000000..6aa7993550 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTrgeometryGeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the 2D trgeometry instant is ever equal to the static geometry. + */ +class EverEqTrgeometryGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTrgeometryGeo"; + + EverEqTrgeometryGeoLogicalFunction(LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction tgt_wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeGeoTrgeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeGeoTrgeometryLogicalFunction.hpp new file mode 100644 index 0000000000..b398288d1a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeGeoTrgeometryLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the static geometry is ever not equal to the 2D trgeometry instant. + */ +class EverNeGeoTrgeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeGeoTrgeometry"; + + EverNeGeoTrgeometryLogicalFunction(LogicalFunction tgt_wkt, LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTrgeometryGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTrgeometryGeoLogicalFunction.hpp new file mode 100644 index 0000000000..1cd767f548 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTrgeometryGeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the 2D trgeometry instant is ever not equal to the static geometry. + */ +class EverNeTrgeometryGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTrgeometryGeo"; + + EverNeTrgeometryGeoLogicalFunction(LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction tgt_wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/NadTrgeometryGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/NadTrgeometryGeoLogicalFunction.hpp new file mode 100644 index 0000000000..f64aba7e86 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/NadTrgeometryGeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nearest approach distance between a 2D trgeometry instant and a static geometry. + */ +class NadTrgeometryGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "NadTrgeometryGeo"; + + NadTrgeometryGeoLogicalFunction(LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction tgt_wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqGeoTrgeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqGeoTrgeometryLogicalFunction.cpp new file mode 100644 index 0000000000..6e8416413f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqGeoTrgeometryLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqGeoTrgeometryLogicalFunction::AlwaysEqGeoTrgeometryLogicalFunction(LogicalFunction tgt_wkt, LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(tgt_wkt)); + parameters.push_back(std::move(ref_wkt)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysEqGeoTrgeometryLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqGeoTrgeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqGeoTrgeometryLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqGeoTrgeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AlwaysEqGeoTrgeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqGeoTrgeometryLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqGeoTrgeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqGeoTrgeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqGeoTrgeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "tgt_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "ref_wkt must be VARSIZED"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysEqGeoTrgeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqGeoTrgeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AlwaysEqGeoTrgeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AlwaysEqGeoTrgeometryLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTrgeometryGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTrgeometryGeoLogicalFunction.cpp new file mode 100644 index 0000000000..7fe52206ad --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTrgeometryGeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTrgeometryGeoLogicalFunction::AlwaysEqTrgeometryGeoLogicalFunction(LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction tgt_wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ref_wkt)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(tgt_wkt)); +} + +DataType AlwaysEqTrgeometryGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTrgeometryGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTrgeometryGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTrgeometryGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AlwaysEqTrgeometryGeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTrgeometryGeoLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTrgeometryGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTrgeometryGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqTrgeometryGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "ref_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::VARSIZED), "tgt_wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction AlwaysEqTrgeometryGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTrgeometryGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AlwaysEqTrgeometryGeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AlwaysEqTrgeometryGeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeGeoTrgeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeGeoTrgeometryLogicalFunction.cpp new file mode 100644 index 0000000000..2595e70e93 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeGeoTrgeometryLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeGeoTrgeometryLogicalFunction::AlwaysNeGeoTrgeometryLogicalFunction(LogicalFunction tgt_wkt, LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(tgt_wkt)); + parameters.push_back(std::move(ref_wkt)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); +} + +DataType AlwaysNeGeoTrgeometryLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeGeoTrgeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeGeoTrgeometryLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeGeoTrgeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AlwaysNeGeoTrgeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeGeoTrgeometryLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeGeoTrgeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeGeoTrgeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeGeoTrgeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "tgt_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "ref_wkt must be VARSIZED"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysNeGeoTrgeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeGeoTrgeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AlwaysNeGeoTrgeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AlwaysNeGeoTrgeometryLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTrgeometryGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTrgeometryGeoLogicalFunction.cpp new file mode 100644 index 0000000000..e0440066d2 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTrgeometryGeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTrgeometryGeoLogicalFunction::AlwaysNeTrgeometryGeoLogicalFunction(LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction tgt_wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ref_wkt)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(tgt_wkt)); +} + +DataType AlwaysNeTrgeometryGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTrgeometryGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTrgeometryGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTrgeometryGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AlwaysNeTrgeometryGeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTrgeometryGeoLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTrgeometryGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTrgeometryGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeTrgeometryGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "ref_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::VARSIZED), "tgt_wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction AlwaysNeTrgeometryGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTrgeometryGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AlwaysNeTrgeometryGeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AlwaysNeTrgeometryGeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index e992c8d631..251628c2fb 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -410,6 +410,15 @@ add_plugin(AlwaysEqTposeTpose LogicalFunction nes-logical-operators AlwaysEqTpos add_plugin(EverNeTposeTpose LogicalFunction nes-logical-operators EverNeTposeTposeLogicalFunction.cpp) add_plugin(AlwaysNeTposeTpose LogicalFunction nes-logical-operators AlwaysNeTposeTposeLogicalFunction.cpp) add_plugin(NadTposeTpose LogicalFunction nes-logical-operators NadTposeTposeLogicalFunction.cpp) +add_plugin(EverEqTrgeometryGeo LogicalFunction nes-logical-operators EverEqTrgeometryGeoLogicalFunction.cpp) +add_plugin(AlwaysEqTrgeometryGeo LogicalFunction nes-logical-operators AlwaysEqTrgeometryGeoLogicalFunction.cpp) +add_plugin(EverNeTrgeometryGeo LogicalFunction nes-logical-operators EverNeTrgeometryGeoLogicalFunction.cpp) +add_plugin(AlwaysNeTrgeometryGeo LogicalFunction nes-logical-operators AlwaysNeTrgeometryGeoLogicalFunction.cpp) +add_plugin(NadTrgeometryGeo LogicalFunction nes-logical-operators NadTrgeometryGeoLogicalFunction.cpp) +add_plugin(EverEqGeoTrgeometry LogicalFunction nes-logical-operators EverEqGeoTrgeometryLogicalFunction.cpp) +add_plugin(AlwaysEqGeoTrgeometry LogicalFunction nes-logical-operators AlwaysEqGeoTrgeometryLogicalFunction.cpp) +add_plugin(EverNeGeoTrgeometry LogicalFunction nes-logical-operators EverNeGeoTrgeometryLogicalFunction.cpp) +add_plugin(AlwaysNeGeoTrgeometry LogicalFunction nes-logical-operators AlwaysNeGeoTrgeometryLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqGeoTrgeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqGeoTrgeometryLogicalFunction.cpp new file mode 100644 index 0000000000..ebb66482a8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqGeoTrgeometryLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqGeoTrgeometryLogicalFunction::EverEqGeoTrgeometryLogicalFunction(LogicalFunction tgt_wkt, LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(tgt_wkt)); + parameters.push_back(std::move(ref_wkt)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); +} + +DataType EverEqGeoTrgeometryLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqGeoTrgeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqGeoTrgeometryLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqGeoTrgeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EverEqGeoTrgeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqGeoTrgeometryLogicalFunction::getType() const { return NAME; } + +bool EverEqGeoTrgeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqGeoTrgeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqGeoTrgeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "tgt_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "ref_wkt must be VARSIZED"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverEqGeoTrgeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqGeoTrgeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EverEqGeoTrgeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EverEqGeoTrgeometryLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTrgeometryGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTrgeometryGeoLogicalFunction.cpp new file mode 100644 index 0000000000..7cafe5215e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTrgeometryGeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTrgeometryGeoLogicalFunction::EverEqTrgeometryGeoLogicalFunction(LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction tgt_wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ref_wkt)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(tgt_wkt)); +} + +DataType EverEqTrgeometryGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTrgeometryGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTrgeometryGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTrgeometryGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EverEqTrgeometryGeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTrgeometryGeoLogicalFunction::getType() const { return NAME; } + +bool EverEqTrgeometryGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTrgeometryGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqTrgeometryGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "ref_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::VARSIZED), "tgt_wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction EverEqTrgeometryGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTrgeometryGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EverEqTrgeometryGeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EverEqTrgeometryGeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeGeoTrgeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeGeoTrgeometryLogicalFunction.cpp new file mode 100644 index 0000000000..713fd63c7a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeGeoTrgeometryLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeGeoTrgeometryLogicalFunction::EverNeGeoTrgeometryLogicalFunction(LogicalFunction tgt_wkt, LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(tgt_wkt)); + parameters.push_back(std::move(ref_wkt)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); +} + +DataType EverNeGeoTrgeometryLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeGeoTrgeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeGeoTrgeometryLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeGeoTrgeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EverNeGeoTrgeometryLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeGeoTrgeometryLogicalFunction::getType() const { return NAME; } + +bool EverNeGeoTrgeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeGeoTrgeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeGeoTrgeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "tgt_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "ref_wkt must be VARSIZED"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverNeGeoTrgeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeGeoTrgeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EverNeGeoTrgeometryLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EverNeGeoTrgeometryLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTrgeometryGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTrgeometryGeoLogicalFunction.cpp new file mode 100644 index 0000000000..7b26b63505 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTrgeometryGeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTrgeometryGeoLogicalFunction::EverNeTrgeometryGeoLogicalFunction(LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction tgt_wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ref_wkt)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(tgt_wkt)); +} + +DataType EverNeTrgeometryGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTrgeometryGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTrgeometryGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTrgeometryGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EverNeTrgeometryGeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTrgeometryGeoLogicalFunction::getType() const { return NAME; } + +bool EverNeTrgeometryGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTrgeometryGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeTrgeometryGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "ref_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::VARSIZED), "tgt_wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction EverNeTrgeometryGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTrgeometryGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EverNeTrgeometryGeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EverNeTrgeometryGeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/NadTrgeometryGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/NadTrgeometryGeoLogicalFunction.cpp new file mode 100644 index 0000000000..222a503a8f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/NadTrgeometryGeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +NadTrgeometryGeoLogicalFunction::NadTrgeometryGeoLogicalFunction(LogicalFunction ref_wkt, LogicalFunction x, LogicalFunction y, LogicalFunction theta, LogicalFunction ts, LogicalFunction tgt_wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(ref_wkt)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(theta)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(tgt_wkt)); +} + +DataType NadTrgeometryGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction NadTrgeometryGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector NadTrgeometryGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction NadTrgeometryGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "NadTrgeometryGeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view NadTrgeometryGeoLogicalFunction::getType() const { return NAME; } + +bool NadTrgeometryGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string NadTrgeometryGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction NadTrgeometryGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "ref_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "theta must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::VARSIZED), "tgt_wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction NadTrgeometryGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterNadTrgeometryGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "NadTrgeometryGeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return NadTrgeometryGeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqGeoTrgeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqGeoTrgeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..9909f96822 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqGeoTrgeometryPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqGeoTrgeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqGeoTrgeometryPhysicalFunction(PhysicalFunction tgt_wkt, PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTrgeometryGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTrgeometryGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..338a24810d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTrgeometryGeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTrgeometryGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTrgeometryGeoPhysicalFunction(PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction tgt_wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeGeoTrgeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeGeoTrgeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..19ec8bffc2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeGeoTrgeometryPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeGeoTrgeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeGeoTrgeometryPhysicalFunction(PhysicalFunction tgt_wkt, PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTrgeometryGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTrgeometryGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..d6c20db78a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTrgeometryGeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTrgeometryGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTrgeometryGeoPhysicalFunction(PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction tgt_wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqGeoTrgeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqGeoTrgeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..46bb6338b3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqGeoTrgeometryPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqGeoTrgeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqGeoTrgeometryPhysicalFunction(PhysicalFunction tgt_wkt, PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTrgeometryGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTrgeometryGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..2aef973091 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTrgeometryGeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTrgeometryGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTrgeometryGeoPhysicalFunction(PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction tgt_wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeGeoTrgeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeGeoTrgeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..309aa7e04c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeGeoTrgeometryPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeGeoTrgeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeGeoTrgeometryPhysicalFunction(PhysicalFunction tgt_wkt, PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTrgeometryGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTrgeometryGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..b966003db8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTrgeometryGeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTrgeometryGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTrgeometryGeoPhysicalFunction(PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction tgt_wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/NadTrgeometryGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/NadTrgeometryGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..7ed02a4613 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/NadTrgeometryGeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class NadTrgeometryGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + NadTrgeometryGeoPhysicalFunction(PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction tgt_wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqGeoTrgeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqGeoTrgeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..71c5372974 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqGeoTrgeometryPhysicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +AlwaysEqGeoTrgeometryPhysicalFunction::AlwaysEqGeoTrgeometryPhysicalFunction(PhysicalFunction tgt_wkt, PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(tgt_wkt)); + paramFns.push_back(std::move(ref_wkt)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); +} + +VarVal AlwaysEqGeoTrgeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto tgt_wkt = paramFns[0].execute(record, arena); + auto ref_wkt = paramFns[1].execute(record, arena); + auto x = paramFns[2].execute(record, arena).cast(); + auto y = paramFns[3].execute(record, arena).cast(); + auto theta = paramFns[4].execute(record, arena).cast(); + auto ts = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* tgt_wkt, uint32_t tgt_len, const char* ref_wkt, uint32_t ref_len, double x, double y, double theta, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* tgt_str = (char*)malloc(tgt_len + 1); + memcpy(tgt_str, tgt_wkt, tgt_len); tgt_str[tgt_len] = '\0'; + GSERIALIZED* gs_tgt = geom_in(tgt_str, -1); free(tgt_str); + if (!gs_tgt) return 0.0; + char* ref_str = (char*)malloc(ref_len + 1); + memcpy(ref_str, ref_wkt, ref_len); ref_str[ref_len] = '\0'; + GSERIALIZED* gs_ref = geom_in(ref_str, -1); free(ref_str); + if (!gs_ref) { free(gs_tgt); return 0.0; } + Pose* pose = pose_make_2d(x, y, theta, false, 0); + if (!pose) { free(gs_tgt); free(gs_ref); return 0.0; } + TInstant* inst = trgeoinst_make(gs_ref, pose, (TimestampTz)ts); + free(gs_ref); free(pose); + if (!inst) { free(gs_tgt); return 0.0; } + int r = always_eq_geo_trgeometry(gs_tgt, (Temporal*)inst); + free(gs_tgt); free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + tgt_wkt, ref_wkt, x, y, theta, ts); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqGeoTrgeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AlwaysEqGeoTrgeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqGeoTrgeometryPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTrgeometryGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTrgeometryGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..661afb57be --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTrgeometryGeoPhysicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +AlwaysEqTrgeometryGeoPhysicalFunction::AlwaysEqTrgeometryGeoPhysicalFunction(PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction tgt_wkt) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(ref_wkt)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(tgt_wkt)); +} + +VarVal AlwaysEqTrgeometryGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref_wkt = paramFns[0].execute(record, arena); + auto x = paramFns[1].execute(record, arena).cast(); + auto y = paramFns[2].execute(record, arena).cast(); + auto theta = paramFns[3].execute(record, arena).cast(); + auto ts = paramFns[4].execute(record, arena).cast(); + auto tgt_wkt = paramFns[5].execute(record, arena); + const auto result = nautilus::invoke( + +[](const char* ref_wkt, uint32_t ref_len, double x, double y, double theta, uint64_t ts, const char* tgt_wkt, uint32_t tgt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* ref_str = (char*)malloc(ref_len + 1); + memcpy(ref_str, ref_wkt, ref_len); ref_str[ref_len] = '\0'; + GSERIALIZED* gs_ref = geom_in(ref_str, -1); free(ref_str); + if (!gs_ref) return 0.0; + Pose* pose = pose_make_2d(x, y, theta, false, 0); + if (!pose) { free(gs_ref); return 0.0; } + TInstant* inst = trgeoinst_make(gs_ref, pose, (TimestampTz)ts); + free(gs_ref); free(pose); + if (!inst) return 0.0; + char* tgt_str = (char*)malloc(tgt_len + 1); + memcpy(tgt_str, tgt_wkt, tgt_len); tgt_str[tgt_len] = '\0'; + GSERIALIZED* gs_tgt = geom_in(tgt_str, -1); free(tgt_str); + if (!gs_tgt) { free(inst); return 0.0; } + int r = always_eq_trgeometry_geo((Temporal*)inst, gs_tgt); + free(inst); free(gs_tgt); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref_wkt, x, y, theta, ts, tgt_wkt); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTrgeometryGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AlwaysEqTrgeometryGeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTrgeometryGeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeGeoTrgeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeGeoTrgeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..635fe64a38 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeGeoTrgeometryPhysicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +AlwaysNeGeoTrgeometryPhysicalFunction::AlwaysNeGeoTrgeometryPhysicalFunction(PhysicalFunction tgt_wkt, PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(tgt_wkt)); + paramFns.push_back(std::move(ref_wkt)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); +} + +VarVal AlwaysNeGeoTrgeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto tgt_wkt = paramFns[0].execute(record, arena); + auto ref_wkt = paramFns[1].execute(record, arena); + auto x = paramFns[2].execute(record, arena).cast(); + auto y = paramFns[3].execute(record, arena).cast(); + auto theta = paramFns[4].execute(record, arena).cast(); + auto ts = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* tgt_wkt, uint32_t tgt_len, const char* ref_wkt, uint32_t ref_len, double x, double y, double theta, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* tgt_str = (char*)malloc(tgt_len + 1); + memcpy(tgt_str, tgt_wkt, tgt_len); tgt_str[tgt_len] = '\0'; + GSERIALIZED* gs_tgt = geom_in(tgt_str, -1); free(tgt_str); + if (!gs_tgt) return 0.0; + char* ref_str = (char*)malloc(ref_len + 1); + memcpy(ref_str, ref_wkt, ref_len); ref_str[ref_len] = '\0'; + GSERIALIZED* gs_ref = geom_in(ref_str, -1); free(ref_str); + if (!gs_ref) { free(gs_tgt); return 0.0; } + Pose* pose = pose_make_2d(x, y, theta, false, 0); + if (!pose) { free(gs_tgt); free(gs_ref); return 0.0; } + TInstant* inst = trgeoinst_make(gs_ref, pose, (TimestampTz)ts); + free(gs_ref); free(pose); + if (!inst) { free(gs_tgt); return 0.0; } + int r = always_ne_geo_trgeometry(gs_tgt, (Temporal*)inst); + free(gs_tgt); free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + tgt_wkt, ref_wkt, x, y, theta, ts); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeGeoTrgeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AlwaysNeGeoTrgeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeGeoTrgeometryPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTrgeometryGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTrgeometryGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..95049e29ea --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTrgeometryGeoPhysicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +AlwaysNeTrgeometryGeoPhysicalFunction::AlwaysNeTrgeometryGeoPhysicalFunction(PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction tgt_wkt) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(ref_wkt)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(tgt_wkt)); +} + +VarVal AlwaysNeTrgeometryGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref_wkt = paramFns[0].execute(record, arena); + auto x = paramFns[1].execute(record, arena).cast(); + auto y = paramFns[2].execute(record, arena).cast(); + auto theta = paramFns[3].execute(record, arena).cast(); + auto ts = paramFns[4].execute(record, arena).cast(); + auto tgt_wkt = paramFns[5].execute(record, arena); + const auto result = nautilus::invoke( + +[](const char* ref_wkt, uint32_t ref_len, double x, double y, double theta, uint64_t ts, const char* tgt_wkt, uint32_t tgt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* ref_str = (char*)malloc(ref_len + 1); + memcpy(ref_str, ref_wkt, ref_len); ref_str[ref_len] = '\0'; + GSERIALIZED* gs_ref = geom_in(ref_str, -1); free(ref_str); + if (!gs_ref) return 0.0; + Pose* pose = pose_make_2d(x, y, theta, false, 0); + if (!pose) { free(gs_ref); return 0.0; } + TInstant* inst = trgeoinst_make(gs_ref, pose, (TimestampTz)ts); + free(gs_ref); free(pose); + if (!inst) return 0.0; + char* tgt_str = (char*)malloc(tgt_len + 1); + memcpy(tgt_str, tgt_wkt, tgt_len); tgt_str[tgt_len] = '\0'; + GSERIALIZED* gs_tgt = geom_in(tgt_str, -1); free(tgt_str); + if (!gs_tgt) { free(inst); return 0.0; } + int r = always_ne_trgeometry_geo((Temporal*)inst, gs_tgt); + free(inst); free(gs_tgt); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref_wkt, x, y, theta, ts, tgt_wkt); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTrgeometryGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AlwaysNeTrgeometryGeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTrgeometryGeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index cd5a4e12d5..663ffe65b3 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -409,6 +409,15 @@ add_plugin(AlwaysEqTposeTpose PhysicalFunction nes-physical-operators AlwaysEqTp add_plugin(EverNeTposeTpose PhysicalFunction nes-physical-operators EverNeTposeTposePhysicalFunction.cpp) add_plugin(AlwaysNeTposeTpose PhysicalFunction nes-physical-operators AlwaysNeTposeTposePhysicalFunction.cpp) add_plugin(NadTposeTpose PhysicalFunction nes-physical-operators NadTposeTposePhysicalFunction.cpp) +add_plugin(EverEqTrgeometryGeo PhysicalFunction nes-physical-operators EverEqTrgeometryGeoPhysicalFunction.cpp) +add_plugin(AlwaysEqTrgeometryGeo PhysicalFunction nes-physical-operators AlwaysEqTrgeometryGeoPhysicalFunction.cpp) +add_plugin(EverNeTrgeometryGeo PhysicalFunction nes-physical-operators EverNeTrgeometryGeoPhysicalFunction.cpp) +add_plugin(AlwaysNeTrgeometryGeo PhysicalFunction nes-physical-operators AlwaysNeTrgeometryGeoPhysicalFunction.cpp) +add_plugin(NadTrgeometryGeo PhysicalFunction nes-physical-operators NadTrgeometryGeoPhysicalFunction.cpp) +add_plugin(EverEqGeoTrgeometry PhysicalFunction nes-physical-operators EverEqGeoTrgeometryPhysicalFunction.cpp) +add_plugin(AlwaysEqGeoTrgeometry PhysicalFunction nes-physical-operators AlwaysEqGeoTrgeometryPhysicalFunction.cpp) +add_plugin(EverNeGeoTrgeometry PhysicalFunction nes-physical-operators EverNeGeoTrgeometryPhysicalFunction.cpp) +add_plugin(AlwaysNeGeoTrgeometry PhysicalFunction nes-physical-operators AlwaysNeGeoTrgeometryPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EverEqGeoTrgeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqGeoTrgeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..bfc538e63e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqGeoTrgeometryPhysicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +EverEqGeoTrgeometryPhysicalFunction::EverEqGeoTrgeometryPhysicalFunction(PhysicalFunction tgt_wkt, PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(tgt_wkt)); + paramFns.push_back(std::move(ref_wkt)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); +} + +VarVal EverEqGeoTrgeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto tgt_wkt = paramFns[0].execute(record, arena); + auto ref_wkt = paramFns[1].execute(record, arena); + auto x = paramFns[2].execute(record, arena).cast(); + auto y = paramFns[3].execute(record, arena).cast(); + auto theta = paramFns[4].execute(record, arena).cast(); + auto ts = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* tgt_wkt, uint32_t tgt_len, const char* ref_wkt, uint32_t ref_len, double x, double y, double theta, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* tgt_str = (char*)malloc(tgt_len + 1); + memcpy(tgt_str, tgt_wkt, tgt_len); tgt_str[tgt_len] = '\0'; + GSERIALIZED* gs_tgt = geom_in(tgt_str, -1); free(tgt_str); + if (!gs_tgt) return 0.0; + char* ref_str = (char*)malloc(ref_len + 1); + memcpy(ref_str, ref_wkt, ref_len); ref_str[ref_len] = '\0'; + GSERIALIZED* gs_ref = geom_in(ref_str, -1); free(ref_str); + if (!gs_ref) { free(gs_tgt); return 0.0; } + Pose* pose = pose_make_2d(x, y, theta, false, 0); + if (!pose) { free(gs_tgt); free(gs_ref); return 0.0; } + TInstant* inst = trgeoinst_make(gs_ref, pose, (TimestampTz)ts); + free(gs_ref); free(pose); + if (!inst) { free(gs_tgt); return 0.0; } + int r = ever_eq_geo_trgeometry(gs_tgt, (Temporal*)inst); + free(gs_tgt); free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + tgt_wkt, ref_wkt, x, y, theta, ts); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqGeoTrgeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EverEqGeoTrgeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EverEqGeoTrgeometryPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTrgeometryGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTrgeometryGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..75a87fa847 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTrgeometryGeoPhysicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +EverEqTrgeometryGeoPhysicalFunction::EverEqTrgeometryGeoPhysicalFunction(PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction tgt_wkt) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(ref_wkt)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(tgt_wkt)); +} + +VarVal EverEqTrgeometryGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref_wkt = paramFns[0].execute(record, arena); + auto x = paramFns[1].execute(record, arena).cast(); + auto y = paramFns[2].execute(record, arena).cast(); + auto theta = paramFns[3].execute(record, arena).cast(); + auto ts = paramFns[4].execute(record, arena).cast(); + auto tgt_wkt = paramFns[5].execute(record, arena); + const auto result = nautilus::invoke( + +[](const char* ref_wkt, uint32_t ref_len, double x, double y, double theta, uint64_t ts, const char* tgt_wkt, uint32_t tgt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* ref_str = (char*)malloc(ref_len + 1); + memcpy(ref_str, ref_wkt, ref_len); ref_str[ref_len] = '\0'; + GSERIALIZED* gs_ref = geom_in(ref_str, -1); free(ref_str); + if (!gs_ref) return 0.0; + Pose* pose = pose_make_2d(x, y, theta, false, 0); + if (!pose) { free(gs_ref); return 0.0; } + TInstant* inst = trgeoinst_make(gs_ref, pose, (TimestampTz)ts); + free(gs_ref); free(pose); + if (!inst) return 0.0; + char* tgt_str = (char*)malloc(tgt_len + 1); + memcpy(tgt_str, tgt_wkt, tgt_len); tgt_str[tgt_len] = '\0'; + GSERIALIZED* gs_tgt = geom_in(tgt_str, -1); free(tgt_str); + if (!gs_tgt) { free(inst); return 0.0; } + int r = ever_eq_trgeometry_geo((Temporal*)inst, gs_tgt); + free(inst); free(gs_tgt); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref_wkt, x, y, theta, ts, tgt_wkt); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTrgeometryGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EverEqTrgeometryGeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EverEqTrgeometryGeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeGeoTrgeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeGeoTrgeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..efe0c7ca48 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeGeoTrgeometryPhysicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +EverNeGeoTrgeometryPhysicalFunction::EverNeGeoTrgeometryPhysicalFunction(PhysicalFunction tgt_wkt, PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(tgt_wkt)); + paramFns.push_back(std::move(ref_wkt)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); +} + +VarVal EverNeGeoTrgeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto tgt_wkt = paramFns[0].execute(record, arena); + auto ref_wkt = paramFns[1].execute(record, arena); + auto x = paramFns[2].execute(record, arena).cast(); + auto y = paramFns[3].execute(record, arena).cast(); + auto theta = paramFns[4].execute(record, arena).cast(); + auto ts = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* tgt_wkt, uint32_t tgt_len, const char* ref_wkt, uint32_t ref_len, double x, double y, double theta, uint64_t ts) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* tgt_str = (char*)malloc(tgt_len + 1); + memcpy(tgt_str, tgt_wkt, tgt_len); tgt_str[tgt_len] = '\0'; + GSERIALIZED* gs_tgt = geom_in(tgt_str, -1); free(tgt_str); + if (!gs_tgt) return 0.0; + char* ref_str = (char*)malloc(ref_len + 1); + memcpy(ref_str, ref_wkt, ref_len); ref_str[ref_len] = '\0'; + GSERIALIZED* gs_ref = geom_in(ref_str, -1); free(ref_str); + if (!gs_ref) { free(gs_tgt); return 0.0; } + Pose* pose = pose_make_2d(x, y, theta, false, 0); + if (!pose) { free(gs_tgt); free(gs_ref); return 0.0; } + TInstant* inst = trgeoinst_make(gs_ref, pose, (TimestampTz)ts); + free(gs_ref); free(pose); + if (!inst) { free(gs_tgt); return 0.0; } + int r = ever_ne_geo_trgeometry(gs_tgt, (Temporal*)inst); + free(gs_tgt); free(inst); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + tgt_wkt, ref_wkt, x, y, theta, ts); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeGeoTrgeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EverNeGeoTrgeometryPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EverNeGeoTrgeometryPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTrgeometryGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTrgeometryGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..f0a6d1da5a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTrgeometryGeoPhysicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +EverNeTrgeometryGeoPhysicalFunction::EverNeTrgeometryGeoPhysicalFunction(PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction tgt_wkt) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(ref_wkt)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(tgt_wkt)); +} + +VarVal EverNeTrgeometryGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref_wkt = paramFns[0].execute(record, arena); + auto x = paramFns[1].execute(record, arena).cast(); + auto y = paramFns[2].execute(record, arena).cast(); + auto theta = paramFns[3].execute(record, arena).cast(); + auto ts = paramFns[4].execute(record, arena).cast(); + auto tgt_wkt = paramFns[5].execute(record, arena); + const auto result = nautilus::invoke( + +[](const char* ref_wkt, uint32_t ref_len, double x, double y, double theta, uint64_t ts, const char* tgt_wkt, uint32_t tgt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* ref_str = (char*)malloc(ref_len + 1); + memcpy(ref_str, ref_wkt, ref_len); ref_str[ref_len] = '\0'; + GSERIALIZED* gs_ref = geom_in(ref_str, -1); free(ref_str); + if (!gs_ref) return 0.0; + Pose* pose = pose_make_2d(x, y, theta, false, 0); + if (!pose) { free(gs_ref); return 0.0; } + TInstant* inst = trgeoinst_make(gs_ref, pose, (TimestampTz)ts); + free(gs_ref); free(pose); + if (!inst) return 0.0; + char* tgt_str = (char*)malloc(tgt_len + 1); + memcpy(tgt_str, tgt_wkt, tgt_len); tgt_str[tgt_len] = '\0'; + GSERIALIZED* gs_tgt = geom_in(tgt_str, -1); free(tgt_str); + if (!gs_tgt) { free(inst); return 0.0; } + int r = ever_ne_trgeometry_geo((Temporal*)inst, gs_tgt); + free(inst); free(gs_tgt); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref_wkt, x, y, theta, ts, tgt_wkt); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTrgeometryGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EverNeTrgeometryGeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EverNeTrgeometryGeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/NadTrgeometryGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/NadTrgeometryGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..850aa84dd8 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/NadTrgeometryGeoPhysicalFunction.cpp @@ -0,0 +1,98 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +NadTrgeometryGeoPhysicalFunction::NadTrgeometryGeoPhysicalFunction(PhysicalFunction ref_wkt, PhysicalFunction x, PhysicalFunction y, PhysicalFunction theta, PhysicalFunction ts, PhysicalFunction tgt_wkt) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(ref_wkt)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(theta)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(tgt_wkt)); +} + +VarVal NadTrgeometryGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref_wkt = paramFns[0].execute(record, arena); + auto x = paramFns[1].execute(record, arena).cast(); + auto y = paramFns[2].execute(record, arena).cast(); + auto theta = paramFns[3].execute(record, arena).cast(); + auto ts = paramFns[4].execute(record, arena).cast(); + auto tgt_wkt = paramFns[5].execute(record, arena); + const auto result = nautilus::invoke( + +[](const char* ref_wkt, uint32_t ref_len, double x, double y, double theta, uint64_t ts, const char* tgt_wkt, uint32_t tgt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* ref_str = (char*)malloc(ref_len + 1); + memcpy(ref_str, ref_wkt, ref_len); ref_str[ref_len] = '\0'; + GSERIALIZED* gs_ref = geom_in(ref_str, -1); free(ref_str); + if (!gs_ref) return 0.0; + Pose* pose = pose_make_2d(x, y, theta, false, 0); + if (!pose) { free(gs_ref); return 0.0; } + TInstant* inst = trgeoinst_make(gs_ref, pose, (TimestampTz)ts); + free(gs_ref); free(pose); + if (!inst) return 0.0; + char* tgt_str = (char*)malloc(tgt_len + 1); + memcpy(tgt_str, tgt_wkt, tgt_len); tgt_str[tgt_len] = '\0'; + GSERIALIZED* gs_tgt = geom_in(tgt_str, -1); free(tgt_str); + if (!gs_tgt) { free(inst); return 0.0; } + double r = nad_trgeometry_geo((Temporal*)inst, gs_tgt); + free(inst); free(gs_tgt); + return r; + } catch (const std::exception&) { return 0.0; } + }, + ref_wkt, x, y, theta, ts, tgt_wkt); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterNadTrgeometryGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "NadTrgeometryGeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return NadTrgeometryGeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 921fdee9c3..2898b8cc13 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -880,6 +880,15 @@ ALWAYS_EQ_TPOSE_TPOSE: 'ALWAYS_EQ_TPOSE_TPOSE' | 'always_eq_tpose_tpose'; EVER_NE_TPOSE_TPOSE: 'EVER_NE_TPOSE_TPOSE' | 'ever_ne_tpose_tpose'; ALWAYS_NE_TPOSE_TPOSE: 'ALWAYS_NE_TPOSE_TPOSE' | 'always_ne_tpose_tpose'; NAD_TPOSE_TPOSE: 'NAD_TPOSE_TPOSE' | 'nad_tpose_tpose'; +EVER_EQ_TRGEOMETRY_GEO: 'EVER_EQ_TRGEOMETRY_GEO' | 'ever_eq_trgeometry_geo'; +ALWAYS_EQ_TRGEOMETRY_GEO: 'ALWAYS_EQ_TRGEOMETRY_GEO' | 'always_eq_trgeometry_geo'; +EVER_NE_TRGEOMETRY_GEO: 'EVER_NE_TRGEOMETRY_GEO' | 'ever_ne_trgeometry_geo'; +ALWAYS_NE_TRGEOMETRY_GEO: 'ALWAYS_NE_TRGEOMETRY_GEO' | 'always_ne_trgeometry_geo'; +NAD_TRGEOMETRY_GEO: 'NAD_TRGEOMETRY_GEO' | 'nad_trgeometry_geo'; +EVER_EQ_GEO_TRGEOMETRY: 'EVER_EQ_GEO_TRGEOMETRY' | 'ever_eq_geo_trgeometry'; +ALWAYS_EQ_GEO_TRGEOMETRY: 'ALWAYS_EQ_GEO_TRGEOMETRY' | 'always_eq_geo_trgeometry'; +EVER_NE_GEO_TRGEOMETRY: 'EVER_NE_GEO_TRGEOMETRY' | 'ever_ne_geo_trgeometry'; +ALWAYS_NE_GEO_TRGEOMETRY: 'ALWAYS_NE_GEO_TRGEOMETRY' | 'always_ne_geo_trgeometry'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index c00cd35b42..2eeeb29e3f 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -461,6 +461,15 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -10360,6 +10369,123 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(NadTposeTposeLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7))); } /* END CODEGEN PARSER GLUE: NAD_TPOSE_TPOSE */ + case AntlrSQLParser::EVER_EQ_TRGEOMETRY_GEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "EverEqTrgeometryGeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EverEqTrgeometryGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_TRGEOMETRY_GEO */ + case AntlrSQLParser::ALWAYS_EQ_TRGEOMETRY_GEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "AlwaysEqTrgeometryGeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AlwaysEqTrgeometryGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TRGEOMETRY_GEO */ + case AntlrSQLParser::EVER_NE_TRGEOMETRY_GEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "EverNeTrgeometryGeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EverNeTrgeometryGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_TRGEOMETRY_GEO */ + case AntlrSQLParser::ALWAYS_NE_TRGEOMETRY_GEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "AlwaysNeTrgeometryGeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AlwaysNeTrgeometryGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TRGEOMETRY_GEO */ + case AntlrSQLParser::NAD_TRGEOMETRY_GEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "NadTrgeometryGeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(NadTrgeometryGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: NAD_TRGEOMETRY_GEO */ + case AntlrSQLParser::EVER_EQ_GEO_TRGEOMETRY: { + PRECONDITION(ctx->functionParam().size() == 6, + "EverEqGeoTrgeometry requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EverEqGeoTrgeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_GEO_TRGEOMETRY */ + case AntlrSQLParser::ALWAYS_EQ_GEO_TRGEOMETRY: { + PRECONDITION(ctx->functionParam().size() == 6, + "AlwaysEqGeoTrgeometry requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AlwaysEqGeoTrgeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_GEO_TRGEOMETRY */ + case AntlrSQLParser::EVER_NE_GEO_TRGEOMETRY: { + PRECONDITION(ctx->functionParam().size() == 6, + "EverNeGeoTrgeometry requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EverNeGeoTrgeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_GEO_TRGEOMETRY */ + case AntlrSQLParser::ALWAYS_NE_GEO_TRGEOMETRY: { + PRECONDITION(ctx->functionParam().size() == 6, + "AlwaysNeGeoTrgeometry requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AlwaysNeGeoTrgeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_GEO_TRGEOMETRY */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From a6dd806a577fee7acb803cf9283b2fe162b95b45 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 10:19:35 +0200 Subject: [PATCH 71/86] feat(meos): add trgeometry_trgeometry 2D per-event scalar operators (W123) Wires five trgeometry-vs-trgeometry per-event scalar operators using a 10-arg dual-VARCHAR two-instant pattern (ref1_wkt:VARCHAR, x1:FLOAT64, y1:FLOAT64, theta1:FLOAT64, ts1:UINT64, ref2_wkt:VARCHAR, x2:FLOAT64, y2:FLOAT64, theta2:FLOAT64, ts2:UINT64) -> FLOAT64. Each physical function builds two 2D trgeometry instants via geom_in(ref_wkt), pose_make_2d, and trgeoinst_make. Operators: EVER_EQ/ALWAYS_EQ/EVER_NE/ALWAYS_NE_TRGEOMETRY_TRGEOMETRY (return 0.0/1.0) and NAD_TRGEOMETRY_TRGEOMETRY (distance or 0.0 on error). --- ...sEqTrgeometryTrgeometryLogicalFunction.hpp | 48 +++++++ ...sNeTrgeometryTrgeometryLogicalFunction.hpp | 48 +++++++ ...rEqTrgeometryTrgeometryLogicalFunction.hpp | 48 +++++++ ...rNeTrgeometryTrgeometryLogicalFunction.hpp | 48 +++++++ ...NadTrgeometryTrgeometryLogicalFunction.hpp | 48 +++++++ ...sEqTrgeometryTrgeometryLogicalFunction.cpp | 123 ++++++++++++++++++ ...sNeTrgeometryTrgeometryLogicalFunction.cpp | 123 ++++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + ...rEqTrgeometryTrgeometryLogicalFunction.cpp | 123 ++++++++++++++++++ ...rNeTrgeometryTrgeometryLogicalFunction.cpp | 123 ++++++++++++++++++ ...NadTrgeometryTrgeometryLogicalFunction.cpp | 123 ++++++++++++++++++ ...EqTrgeometryTrgeometryPhysicalFunction.hpp | 32 +++++ ...NeTrgeometryTrgeometryPhysicalFunction.hpp | 32 +++++ ...EqTrgeometryTrgeometryPhysicalFunction.hpp | 32 +++++ ...NeTrgeometryTrgeometryPhysicalFunction.hpp | 32 +++++ ...adTrgeometryTrgeometryPhysicalFunction.hpp | 32 +++++ ...EqTrgeometryTrgeometryPhysicalFunction.cpp | 115 ++++++++++++++++ ...NeTrgeometryTrgeometryPhysicalFunction.cpp | 115 ++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 5 + ...EqTrgeometryTrgeometryPhysicalFunction.cpp | 115 ++++++++++++++++ ...NeTrgeometryTrgeometryPhysicalFunction.cpp | 115 ++++++++++++++++ ...adTrgeometryTrgeometryPhysicalFunction.cpp | 115 ++++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 7 +- .../src/AntlrSQLQueryPlanCreator.cpp | 90 +++++++++++++ 24 files changed, 1696 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTrgeometryTrgeometryLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTrgeometryTrgeometryLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTrgeometryTrgeometryLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTrgeometryTrgeometryLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/NadTrgeometryTrgeometryLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTrgeometryTrgeometryLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTrgeometryTrgeometryLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTrgeometryTrgeometryLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTrgeometryTrgeometryLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/NadTrgeometryTrgeometryLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTrgeometryTrgeometryPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTrgeometryTrgeometryPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTrgeometryTrgeometryPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTrgeometryTrgeometryPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/NadTrgeometryTrgeometryPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTrgeometryTrgeometryPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTrgeometryTrgeometryPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTrgeometryTrgeometryPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTrgeometryTrgeometryPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/NadTrgeometryTrgeometryPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTrgeometryTrgeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTrgeometryTrgeometryLogicalFunction.hpp new file mode 100644 index 0000000000..d4c94d1d96 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTrgeometryTrgeometryLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two 2D trgeometry instants are always equal. + */ +class AlwaysEqTrgeometryTrgeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTrgeometryTrgeometry"; + + AlwaysEqTrgeometryTrgeometryLogicalFunction(LogicalFunction ref1_wkt, LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, LogicalFunction ref2_wkt, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTrgeometryTrgeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTrgeometryTrgeometryLogicalFunction.hpp new file mode 100644 index 0000000000..7a8ff6f177 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTrgeometryTrgeometryLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two 2D trgeometry instants are always not equal. + */ +class AlwaysNeTrgeometryTrgeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTrgeometryTrgeometry"; + + AlwaysNeTrgeometryTrgeometryLogicalFunction(LogicalFunction ref1_wkt, LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, LogicalFunction ref2_wkt, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTrgeometryTrgeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTrgeometryTrgeometryLogicalFunction.hpp new file mode 100644 index 0000000000..14e66d2256 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTrgeometryTrgeometryLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two 2D trgeometry instants are ever equal. + */ +class EverEqTrgeometryTrgeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTrgeometryTrgeometry"; + + EverEqTrgeometryTrgeometryLogicalFunction(LogicalFunction ref1_wkt, LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, LogicalFunction ref2_wkt, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTrgeometryTrgeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTrgeometryTrgeometryLogicalFunction.hpp new file mode 100644 index 0000000000..100e057f87 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTrgeometryTrgeometryLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two 2D trgeometry instants are ever not equal. + */ +class EverNeTrgeometryTrgeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTrgeometryTrgeometry"; + + EverNeTrgeometryTrgeometryLogicalFunction(LogicalFunction ref1_wkt, LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, LogicalFunction ref2_wkt, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/NadTrgeometryTrgeometryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/NadTrgeometryTrgeometryLogicalFunction.hpp new file mode 100644 index 0000000000..59906eb1d9 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/NadTrgeometryTrgeometryLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nearest approach distance between two 2D trgeometry instants. + */ +class NadTrgeometryTrgeometryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "NadTrgeometryTrgeometry"; + + NadTrgeometryTrgeometryLogicalFunction(LogicalFunction ref1_wkt, LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, LogicalFunction ref2_wkt, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTrgeometryTrgeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTrgeometryTrgeometryLogicalFunction.cpp new file mode 100644 index 0000000000..e24340ca8e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTrgeometryTrgeometryLogicalFunction.cpp @@ -0,0 +1,123 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTrgeometryTrgeometryLogicalFunction::AlwaysEqTrgeometryTrgeometryLogicalFunction(LogicalFunction ref1_wkt, LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, LogicalFunction ref2_wkt, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(10); + parameters.push_back(std::move(ref1_wkt)); + parameters.push_back(std::move(x1)); + parameters.push_back(std::move(y1)); + parameters.push_back(std::move(theta1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(ref2_wkt)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(ts2)); +} + +DataType AlwaysEqTrgeometryTrgeometryLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTrgeometryTrgeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTrgeometryTrgeometryLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTrgeometryTrgeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 10, + "AlwaysEqTrgeometryTrgeometryLogicalFunction requires 10 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTrgeometryTrgeometryLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTrgeometryTrgeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTrgeometryTrgeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqTrgeometryTrgeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(10); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "ref1_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "theta1 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::VARSIZED), "ref2_wkt must be VARSIZED"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[8].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[9].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysEqTrgeometryTrgeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTrgeometryTrgeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 10, + "AlwaysEqTrgeometryTrgeometryLogicalFunction requires 10 children but got {}", + arguments.children.size()); + return AlwaysEqTrgeometryTrgeometryLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7]), + std::move(arguments.children[8]), + std::move(arguments.children[9])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTrgeometryTrgeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTrgeometryTrgeometryLogicalFunction.cpp new file mode 100644 index 0000000000..be1f419995 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTrgeometryTrgeometryLogicalFunction.cpp @@ -0,0 +1,123 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTrgeometryTrgeometryLogicalFunction::AlwaysNeTrgeometryTrgeometryLogicalFunction(LogicalFunction ref1_wkt, LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, LogicalFunction ref2_wkt, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(10); + parameters.push_back(std::move(ref1_wkt)); + parameters.push_back(std::move(x1)); + parameters.push_back(std::move(y1)); + parameters.push_back(std::move(theta1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(ref2_wkt)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(ts2)); +} + +DataType AlwaysNeTrgeometryTrgeometryLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTrgeometryTrgeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTrgeometryTrgeometryLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTrgeometryTrgeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 10, + "AlwaysNeTrgeometryTrgeometryLogicalFunction requires 10 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTrgeometryTrgeometryLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTrgeometryTrgeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTrgeometryTrgeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeTrgeometryTrgeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(10); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "ref1_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "theta1 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::VARSIZED), "ref2_wkt must be VARSIZED"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[8].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[9].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysNeTrgeometryTrgeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTrgeometryTrgeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 10, + "AlwaysNeTrgeometryTrgeometryLogicalFunction requires 10 children but got {}", + arguments.children.size()); + return AlwaysNeTrgeometryTrgeometryLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7]), + std::move(arguments.children[8]), + std::move(arguments.children[9])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 251628c2fb..d4ada48eac 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -419,6 +419,11 @@ add_plugin(EverEqGeoTrgeometry LogicalFunction nes-logical-operators EverEqGeoTr add_plugin(AlwaysEqGeoTrgeometry LogicalFunction nes-logical-operators AlwaysEqGeoTrgeometryLogicalFunction.cpp) add_plugin(EverNeGeoTrgeometry LogicalFunction nes-logical-operators EverNeGeoTrgeometryLogicalFunction.cpp) add_plugin(AlwaysNeGeoTrgeometry LogicalFunction nes-logical-operators AlwaysNeGeoTrgeometryLogicalFunction.cpp) +add_plugin(EverEqTrgeometryTrgeometry LogicalFunction nes-logical-operators EverEqTrgeometryTrgeometryLogicalFunction.cpp) +add_plugin(AlwaysEqTrgeometryTrgeometry LogicalFunction nes-logical-operators AlwaysEqTrgeometryTrgeometryLogicalFunction.cpp) +add_plugin(EverNeTrgeometryTrgeometry LogicalFunction nes-logical-operators EverNeTrgeometryTrgeometryLogicalFunction.cpp) +add_plugin(AlwaysNeTrgeometryTrgeometry LogicalFunction nes-logical-operators AlwaysNeTrgeometryTrgeometryLogicalFunction.cpp) +add_plugin(NadTrgeometryTrgeometry LogicalFunction nes-logical-operators NadTrgeometryTrgeometryLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTrgeometryTrgeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTrgeometryTrgeometryLogicalFunction.cpp new file mode 100644 index 0000000000..c515021fdb --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTrgeometryTrgeometryLogicalFunction.cpp @@ -0,0 +1,123 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTrgeometryTrgeometryLogicalFunction::EverEqTrgeometryTrgeometryLogicalFunction(LogicalFunction ref1_wkt, LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, LogicalFunction ref2_wkt, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(10); + parameters.push_back(std::move(ref1_wkt)); + parameters.push_back(std::move(x1)); + parameters.push_back(std::move(y1)); + parameters.push_back(std::move(theta1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(ref2_wkt)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(ts2)); +} + +DataType EverEqTrgeometryTrgeometryLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTrgeometryTrgeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTrgeometryTrgeometryLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTrgeometryTrgeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 10, + "EverEqTrgeometryTrgeometryLogicalFunction requires 10 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTrgeometryTrgeometryLogicalFunction::getType() const { return NAME; } + +bool EverEqTrgeometryTrgeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTrgeometryTrgeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqTrgeometryTrgeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(10); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "ref1_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "theta1 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::VARSIZED), "ref2_wkt must be VARSIZED"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[8].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[9].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverEqTrgeometryTrgeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTrgeometryTrgeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 10, + "EverEqTrgeometryTrgeometryLogicalFunction requires 10 children but got {}", + arguments.children.size()); + return EverEqTrgeometryTrgeometryLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7]), + std::move(arguments.children[8]), + std::move(arguments.children[9])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTrgeometryTrgeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTrgeometryTrgeometryLogicalFunction.cpp new file mode 100644 index 0000000000..c9d2a7406c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTrgeometryTrgeometryLogicalFunction.cpp @@ -0,0 +1,123 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTrgeometryTrgeometryLogicalFunction::EverNeTrgeometryTrgeometryLogicalFunction(LogicalFunction ref1_wkt, LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, LogicalFunction ref2_wkt, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(10); + parameters.push_back(std::move(ref1_wkt)); + parameters.push_back(std::move(x1)); + parameters.push_back(std::move(y1)); + parameters.push_back(std::move(theta1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(ref2_wkt)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(ts2)); +} + +DataType EverNeTrgeometryTrgeometryLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTrgeometryTrgeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTrgeometryTrgeometryLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTrgeometryTrgeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 10, + "EverNeTrgeometryTrgeometryLogicalFunction requires 10 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTrgeometryTrgeometryLogicalFunction::getType() const { return NAME; } + +bool EverNeTrgeometryTrgeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTrgeometryTrgeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeTrgeometryTrgeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(10); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "ref1_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "theta1 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::VARSIZED), "ref2_wkt must be VARSIZED"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[8].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[9].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverNeTrgeometryTrgeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTrgeometryTrgeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 10, + "EverNeTrgeometryTrgeometryLogicalFunction requires 10 children but got {}", + arguments.children.size()); + return EverNeTrgeometryTrgeometryLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7]), + std::move(arguments.children[8]), + std::move(arguments.children[9])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/NadTrgeometryTrgeometryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/NadTrgeometryTrgeometryLogicalFunction.cpp new file mode 100644 index 0000000000..1785fef017 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/NadTrgeometryTrgeometryLogicalFunction.cpp @@ -0,0 +1,123 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +NadTrgeometryTrgeometryLogicalFunction::NadTrgeometryTrgeometryLogicalFunction(LogicalFunction ref1_wkt, LogicalFunction x1, LogicalFunction y1, LogicalFunction theta1, LogicalFunction ts1, LogicalFunction ref2_wkt, LogicalFunction x2, LogicalFunction y2, LogicalFunction theta2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(10); + parameters.push_back(std::move(ref1_wkt)); + parameters.push_back(std::move(x1)); + parameters.push_back(std::move(y1)); + parameters.push_back(std::move(theta1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(ref2_wkt)); + parameters.push_back(std::move(x2)); + parameters.push_back(std::move(y2)); + parameters.push_back(std::move(theta2)); + parameters.push_back(std::move(ts2)); +} + +DataType NadTrgeometryTrgeometryLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction NadTrgeometryTrgeometryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector NadTrgeometryTrgeometryLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction NadTrgeometryTrgeometryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 10, + "NadTrgeometryTrgeometryLogicalFunction requires 10 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view NadTrgeometryTrgeometryLogicalFunction::getType() const { return NAME; } + +bool NadTrgeometryTrgeometryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string NadTrgeometryTrgeometryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction NadTrgeometryTrgeometryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(10); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "ref1_wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y1 must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "theta1 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::VARSIZED), "ref2_wkt must be VARSIZED"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "x2 must be FLOAT64"); + INVARIANT(c[7].getDataType().isType(DataType::Type::FLOAT64), "y2 must be FLOAT64"); + INVARIANT(c[8].getDataType().isType(DataType::Type::FLOAT64), "theta2 must be FLOAT64"); + INVARIANT(c[9].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction NadTrgeometryTrgeometryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterNadTrgeometryTrgeometryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 10, + "NadTrgeometryTrgeometryLogicalFunction requires 10 children but got {}", + arguments.children.size()); + return NadTrgeometryTrgeometryLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6]), + std::move(arguments.children[7]), + std::move(arguments.children[8]), + std::move(arguments.children[9])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTrgeometryTrgeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTrgeometryTrgeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..00f5c0d7b4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTrgeometryTrgeometryPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTrgeometryTrgeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTrgeometryTrgeometryPhysicalFunction(PhysicalFunction ref1_wkt, PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, PhysicalFunction ref2_wkt, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTrgeometryTrgeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTrgeometryTrgeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..c830b1b5f1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTrgeometryTrgeometryPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTrgeometryTrgeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTrgeometryTrgeometryPhysicalFunction(PhysicalFunction ref1_wkt, PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, PhysicalFunction ref2_wkt, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTrgeometryTrgeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTrgeometryTrgeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..53c9a1f285 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTrgeometryTrgeometryPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTrgeometryTrgeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTrgeometryTrgeometryPhysicalFunction(PhysicalFunction ref1_wkt, PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, PhysicalFunction ref2_wkt, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTrgeometryTrgeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTrgeometryTrgeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..98824f26d6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTrgeometryTrgeometryPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTrgeometryTrgeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTrgeometryTrgeometryPhysicalFunction(PhysicalFunction ref1_wkt, PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, PhysicalFunction ref2_wkt, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/NadTrgeometryTrgeometryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/NadTrgeometryTrgeometryPhysicalFunction.hpp new file mode 100644 index 0000000000..b138dd9908 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/NadTrgeometryTrgeometryPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class NadTrgeometryTrgeometryPhysicalFunction : public PhysicalFunctionConcept { +public: + NadTrgeometryTrgeometryPhysicalFunction(PhysicalFunction ref1_wkt, PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, PhysicalFunction ref2_wkt, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTrgeometryTrgeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTrgeometryTrgeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..8413d1785f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTrgeometryTrgeometryPhysicalFunction.cpp @@ -0,0 +1,115 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +AlwaysEqTrgeometryTrgeometryPhysicalFunction::AlwaysEqTrgeometryTrgeometryPhysicalFunction(PhysicalFunction ref1_wkt, PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, PhysicalFunction ref2_wkt, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2) +{ + paramFns.reserve(10); + paramFns.push_back(std::move(ref1_wkt)); + paramFns.push_back(std::move(x1)); + paramFns.push_back(std::move(y1)); + paramFns.push_back(std::move(theta1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(ref2_wkt)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AlwaysEqTrgeometryTrgeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref1_wkt = paramFns[0].execute(record, arena); + auto x1 = paramFns[1].execute(record, arena).cast(); + auto y1 = paramFns[2].execute(record, arena).cast(); + auto theta1 = paramFns[3].execute(record, arena).cast(); + auto ts1 = paramFns[4].execute(record, arena).cast(); + auto ref2_wkt = paramFns[5].execute(record, arena); + auto x2 = paramFns[6].execute(record, arena).cast(); + auto y2 = paramFns[7].execute(record, arena).cast(); + auto theta2 = paramFns[8].execute(record, arena).cast(); + auto ts2 = paramFns[9].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* ref1_wkt, uint32_t ref1_len, double x1, double y1, double theta1, uint64_t ts1, const char* ref2_wkt, uint32_t ref2_len, double x2, double y2, double theta2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s1 = (char*)malloc(ref1_len + 1); + memcpy(s1, ref1_wkt, ref1_len); s1[ref1_len] = '\0'; + GSERIALIZED* gs1 = geom_in(s1, -1); free(s1); + if (!gs1) return 0.0; + Pose* p1 = pose_make_2d(x1, y1, theta1, false, 0); + if (!p1) { free(gs1); return 0.0; } + TInstant* inst1 = trgeoinst_make(gs1, p1, (TimestampTz)ts1); + free(gs1); free(p1); + if (!inst1) return 0.0; + char* s2 = (char*)malloc(ref2_len + 1); + memcpy(s2, ref2_wkt, ref2_len); s2[ref2_len] = '\0'; + GSERIALIZED* gs2 = geom_in(s2, -1); free(s2); + if (!gs2) { free(inst1); return 0.0; } + Pose* p2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!p2) { free(inst1); free(gs2); return 0.0; } + TInstant* inst2 = trgeoinst_make(gs2, p2, (TimestampTz)ts2); + free(gs2); free(p2); + if (!inst2) { free(inst1); return 0.0; } + int r = always_eq_trgeometry_trgeometry((Temporal*)inst1, (Temporal*)inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref1_wkt, x1, y1, theta1, ts1, ref2_wkt, x2, y2, theta2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTrgeometryTrgeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 10, + "AlwaysEqTrgeometryTrgeometryPhysicalFunction requires 10 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTrgeometryTrgeometryPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7]), + std::move(arguments.childFunctions[8]), + std::move(arguments.childFunctions[9])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTrgeometryTrgeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTrgeometryTrgeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..5c4e5acda6 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTrgeometryTrgeometryPhysicalFunction.cpp @@ -0,0 +1,115 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +AlwaysNeTrgeometryTrgeometryPhysicalFunction::AlwaysNeTrgeometryTrgeometryPhysicalFunction(PhysicalFunction ref1_wkt, PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, PhysicalFunction ref2_wkt, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2) +{ + paramFns.reserve(10); + paramFns.push_back(std::move(ref1_wkt)); + paramFns.push_back(std::move(x1)); + paramFns.push_back(std::move(y1)); + paramFns.push_back(std::move(theta1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(ref2_wkt)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AlwaysNeTrgeometryTrgeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref1_wkt = paramFns[0].execute(record, arena); + auto x1 = paramFns[1].execute(record, arena).cast(); + auto y1 = paramFns[2].execute(record, arena).cast(); + auto theta1 = paramFns[3].execute(record, arena).cast(); + auto ts1 = paramFns[4].execute(record, arena).cast(); + auto ref2_wkt = paramFns[5].execute(record, arena); + auto x2 = paramFns[6].execute(record, arena).cast(); + auto y2 = paramFns[7].execute(record, arena).cast(); + auto theta2 = paramFns[8].execute(record, arena).cast(); + auto ts2 = paramFns[9].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* ref1_wkt, uint32_t ref1_len, double x1, double y1, double theta1, uint64_t ts1, const char* ref2_wkt, uint32_t ref2_len, double x2, double y2, double theta2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s1 = (char*)malloc(ref1_len + 1); + memcpy(s1, ref1_wkt, ref1_len); s1[ref1_len] = '\0'; + GSERIALIZED* gs1 = geom_in(s1, -1); free(s1); + if (!gs1) return 0.0; + Pose* p1 = pose_make_2d(x1, y1, theta1, false, 0); + if (!p1) { free(gs1); return 0.0; } + TInstant* inst1 = trgeoinst_make(gs1, p1, (TimestampTz)ts1); + free(gs1); free(p1); + if (!inst1) return 0.0; + char* s2 = (char*)malloc(ref2_len + 1); + memcpy(s2, ref2_wkt, ref2_len); s2[ref2_len] = '\0'; + GSERIALIZED* gs2 = geom_in(s2, -1); free(s2); + if (!gs2) { free(inst1); return 0.0; } + Pose* p2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!p2) { free(inst1); free(gs2); return 0.0; } + TInstant* inst2 = trgeoinst_make(gs2, p2, (TimestampTz)ts2); + free(gs2); free(p2); + if (!inst2) { free(inst1); return 0.0; } + int r = always_ne_trgeometry_trgeometry((Temporal*)inst1, (Temporal*)inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref1_wkt, x1, y1, theta1, ts1, ref2_wkt, x2, y2, theta2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTrgeometryTrgeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 10, + "AlwaysNeTrgeometryTrgeometryPhysicalFunction requires 10 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTrgeometryTrgeometryPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7]), + std::move(arguments.childFunctions[8]), + std::move(arguments.childFunctions[9])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 663ffe65b3..74c4b79187 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -418,6 +418,11 @@ add_plugin(EverEqGeoTrgeometry PhysicalFunction nes-physical-operators EverEqGeo add_plugin(AlwaysEqGeoTrgeometry PhysicalFunction nes-physical-operators AlwaysEqGeoTrgeometryPhysicalFunction.cpp) add_plugin(EverNeGeoTrgeometry PhysicalFunction nes-physical-operators EverNeGeoTrgeometryPhysicalFunction.cpp) add_plugin(AlwaysNeGeoTrgeometry PhysicalFunction nes-physical-operators AlwaysNeGeoTrgeometryPhysicalFunction.cpp) +add_plugin(EverEqTrgeometryTrgeometry PhysicalFunction nes-physical-operators EverEqTrgeometryTrgeometryPhysicalFunction.cpp) +add_plugin(AlwaysEqTrgeometryTrgeometry PhysicalFunction nes-physical-operators AlwaysEqTrgeometryTrgeometryPhysicalFunction.cpp) +add_plugin(EverNeTrgeometryTrgeometry PhysicalFunction nes-physical-operators EverNeTrgeometryTrgeometryPhysicalFunction.cpp) +add_plugin(AlwaysNeTrgeometryTrgeometry PhysicalFunction nes-physical-operators AlwaysNeTrgeometryTrgeometryPhysicalFunction.cpp) +add_plugin(NadTrgeometryTrgeometry PhysicalFunction nes-physical-operators NadTrgeometryTrgeometryPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTrgeometryTrgeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTrgeometryTrgeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..aeec1c43fd --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTrgeometryTrgeometryPhysicalFunction.cpp @@ -0,0 +1,115 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +EverEqTrgeometryTrgeometryPhysicalFunction::EverEqTrgeometryTrgeometryPhysicalFunction(PhysicalFunction ref1_wkt, PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, PhysicalFunction ref2_wkt, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2) +{ + paramFns.reserve(10); + paramFns.push_back(std::move(ref1_wkt)); + paramFns.push_back(std::move(x1)); + paramFns.push_back(std::move(y1)); + paramFns.push_back(std::move(theta1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(ref2_wkt)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EverEqTrgeometryTrgeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref1_wkt = paramFns[0].execute(record, arena); + auto x1 = paramFns[1].execute(record, arena).cast(); + auto y1 = paramFns[2].execute(record, arena).cast(); + auto theta1 = paramFns[3].execute(record, arena).cast(); + auto ts1 = paramFns[4].execute(record, arena).cast(); + auto ref2_wkt = paramFns[5].execute(record, arena); + auto x2 = paramFns[6].execute(record, arena).cast(); + auto y2 = paramFns[7].execute(record, arena).cast(); + auto theta2 = paramFns[8].execute(record, arena).cast(); + auto ts2 = paramFns[9].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* ref1_wkt, uint32_t ref1_len, double x1, double y1, double theta1, uint64_t ts1, const char* ref2_wkt, uint32_t ref2_len, double x2, double y2, double theta2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s1 = (char*)malloc(ref1_len + 1); + memcpy(s1, ref1_wkt, ref1_len); s1[ref1_len] = '\0'; + GSERIALIZED* gs1 = geom_in(s1, -1); free(s1); + if (!gs1) return 0.0; + Pose* p1 = pose_make_2d(x1, y1, theta1, false, 0); + if (!p1) { free(gs1); return 0.0; } + TInstant* inst1 = trgeoinst_make(gs1, p1, (TimestampTz)ts1); + free(gs1); free(p1); + if (!inst1) return 0.0; + char* s2 = (char*)malloc(ref2_len + 1); + memcpy(s2, ref2_wkt, ref2_len); s2[ref2_len] = '\0'; + GSERIALIZED* gs2 = geom_in(s2, -1); free(s2); + if (!gs2) { free(inst1); return 0.0; } + Pose* p2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!p2) { free(inst1); free(gs2); return 0.0; } + TInstant* inst2 = trgeoinst_make(gs2, p2, (TimestampTz)ts2); + free(gs2); free(p2); + if (!inst2) { free(inst1); return 0.0; } + int r = ever_eq_trgeometry_trgeometry((Temporal*)inst1, (Temporal*)inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref1_wkt, x1, y1, theta1, ts1, ref2_wkt, x2, y2, theta2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTrgeometryTrgeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 10, + "EverEqTrgeometryTrgeometryPhysicalFunction requires 10 children but got {}", + arguments.childFunctions.size()); + return EverEqTrgeometryTrgeometryPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7]), + std::move(arguments.childFunctions[8]), + std::move(arguments.childFunctions[9])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTrgeometryTrgeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTrgeometryTrgeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..347c00a985 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTrgeometryTrgeometryPhysicalFunction.cpp @@ -0,0 +1,115 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +EverNeTrgeometryTrgeometryPhysicalFunction::EverNeTrgeometryTrgeometryPhysicalFunction(PhysicalFunction ref1_wkt, PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, PhysicalFunction ref2_wkt, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2) +{ + paramFns.reserve(10); + paramFns.push_back(std::move(ref1_wkt)); + paramFns.push_back(std::move(x1)); + paramFns.push_back(std::move(y1)); + paramFns.push_back(std::move(theta1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(ref2_wkt)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EverNeTrgeometryTrgeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref1_wkt = paramFns[0].execute(record, arena); + auto x1 = paramFns[1].execute(record, arena).cast(); + auto y1 = paramFns[2].execute(record, arena).cast(); + auto theta1 = paramFns[3].execute(record, arena).cast(); + auto ts1 = paramFns[4].execute(record, arena).cast(); + auto ref2_wkt = paramFns[5].execute(record, arena); + auto x2 = paramFns[6].execute(record, arena).cast(); + auto y2 = paramFns[7].execute(record, arena).cast(); + auto theta2 = paramFns[8].execute(record, arena).cast(); + auto ts2 = paramFns[9].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* ref1_wkt, uint32_t ref1_len, double x1, double y1, double theta1, uint64_t ts1, const char* ref2_wkt, uint32_t ref2_len, double x2, double y2, double theta2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s1 = (char*)malloc(ref1_len + 1); + memcpy(s1, ref1_wkt, ref1_len); s1[ref1_len] = '\0'; + GSERIALIZED* gs1 = geom_in(s1, -1); free(s1); + if (!gs1) return 0.0; + Pose* p1 = pose_make_2d(x1, y1, theta1, false, 0); + if (!p1) { free(gs1); return 0.0; } + TInstant* inst1 = trgeoinst_make(gs1, p1, (TimestampTz)ts1); + free(gs1); free(p1); + if (!inst1) return 0.0; + char* s2 = (char*)malloc(ref2_len + 1); + memcpy(s2, ref2_wkt, ref2_len); s2[ref2_len] = '\0'; + GSERIALIZED* gs2 = geom_in(s2, -1); free(s2); + if (!gs2) { free(inst1); return 0.0; } + Pose* p2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!p2) { free(inst1); free(gs2); return 0.0; } + TInstant* inst2 = trgeoinst_make(gs2, p2, (TimestampTz)ts2); + free(gs2); free(p2); + if (!inst2) { free(inst1); return 0.0; } + int r = ever_ne_trgeometry_trgeometry((Temporal*)inst1, (Temporal*)inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + ref1_wkt, x1, y1, theta1, ts1, ref2_wkt, x2, y2, theta2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTrgeometryTrgeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 10, + "EverNeTrgeometryTrgeometryPhysicalFunction requires 10 children but got {}", + arguments.childFunctions.size()); + return EverNeTrgeometryTrgeometryPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7]), + std::move(arguments.childFunctions[8]), + std::move(arguments.childFunctions[9])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/NadTrgeometryTrgeometryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/NadTrgeometryTrgeometryPhysicalFunction.cpp new file mode 100644 index 0000000000..8c0647504c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/NadTrgeometryTrgeometryPhysicalFunction.cpp @@ -0,0 +1,115 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +namespace NES { + +NadTrgeometryTrgeometryPhysicalFunction::NadTrgeometryTrgeometryPhysicalFunction(PhysicalFunction ref1_wkt, PhysicalFunction x1, PhysicalFunction y1, PhysicalFunction theta1, PhysicalFunction ts1, PhysicalFunction ref2_wkt, PhysicalFunction x2, PhysicalFunction y2, PhysicalFunction theta2, PhysicalFunction ts2) +{ + paramFns.reserve(10); + paramFns.push_back(std::move(ref1_wkt)); + paramFns.push_back(std::move(x1)); + paramFns.push_back(std::move(y1)); + paramFns.push_back(std::move(theta1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(ref2_wkt)); + paramFns.push_back(std::move(x2)); + paramFns.push_back(std::move(y2)); + paramFns.push_back(std::move(theta2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal NadTrgeometryTrgeometryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto ref1_wkt = paramFns[0].execute(record, arena); + auto x1 = paramFns[1].execute(record, arena).cast(); + auto y1 = paramFns[2].execute(record, arena).cast(); + auto theta1 = paramFns[3].execute(record, arena).cast(); + auto ts1 = paramFns[4].execute(record, arena).cast(); + auto ref2_wkt = paramFns[5].execute(record, arena); + auto x2 = paramFns[6].execute(record, arena).cast(); + auto y2 = paramFns[7].execute(record, arena).cast(); + auto theta2 = paramFns[8].execute(record, arena).cast(); + auto ts2 = paramFns[9].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* ref1_wkt, uint32_t ref1_len, double x1, double y1, double theta1, uint64_t ts1, const char* ref2_wkt, uint32_t ref2_len, double x2, double y2, double theta2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s1 = (char*)malloc(ref1_len + 1); + memcpy(s1, ref1_wkt, ref1_len); s1[ref1_len] = '\0'; + GSERIALIZED* gs1 = geom_in(s1, -1); free(s1); + if (!gs1) return 0.0; + Pose* p1 = pose_make_2d(x1, y1, theta1, false, 0); + if (!p1) { free(gs1); return 0.0; } + TInstant* inst1 = trgeoinst_make(gs1, p1, (TimestampTz)ts1); + free(gs1); free(p1); + if (!inst1) return 0.0; + char* s2 = (char*)malloc(ref2_len + 1); + memcpy(s2, ref2_wkt, ref2_len); s2[ref2_len] = '\0'; + GSERIALIZED* gs2 = geom_in(s2, -1); free(s2); + if (!gs2) { free(inst1); return 0.0; } + Pose* p2 = pose_make_2d(x2, y2, theta2, false, 0); + if (!p2) { free(inst1); free(gs2); return 0.0; } + TInstant* inst2 = trgeoinst_make(gs2, p2, (TimestampTz)ts2); + free(gs2); free(p2); + if (!inst2) { free(inst1); return 0.0; } + double r = nad_trgeometry_trgeometry((Temporal*)inst1, (Temporal*)inst2); + free(inst1); free(inst2); + return r; + } catch (const std::exception&) { return 0.0; } + }, + ref1_wkt, x1, y1, theta1, ts1, ref2_wkt, x2, y2, theta2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterNadTrgeometryTrgeometryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 10, + "NadTrgeometryTrgeometryPhysicalFunction requires 10 children but got {}", + arguments.childFunctions.size()); + return NadTrgeometryTrgeometryPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6]), + std::move(arguments.childFunctions[7]), + std::move(arguments.childFunctions[8]), + std::move(arguments.childFunctions[9])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 2898b8cc13..0941f3efb3 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -889,6 +889,11 @@ EVER_EQ_GEO_TRGEOMETRY: 'EVER_EQ_GEO_TRGEOMETRY' | 'ever_eq_geo_trgeometry'; ALWAYS_EQ_GEO_TRGEOMETRY: 'ALWAYS_EQ_GEO_TRGEOMETRY' | 'always_eq_geo_trgeometry'; EVER_NE_GEO_TRGEOMETRY: 'EVER_NE_GEO_TRGEOMETRY' | 'ever_ne_geo_trgeometry'; ALWAYS_NE_GEO_TRGEOMETRY: 'ALWAYS_NE_GEO_TRGEOMETRY' | 'always_ne_geo_trgeometry'; +EVER_EQ_TRGEOMETRY_TRGEOMETRY: 'EVER_EQ_TRGEOMETRY_TRGEOMETRY' | 'ever_eq_trgeometry_trgeometry'; +ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY: 'ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY' | 'always_eq_trgeometry_trgeometry'; +EVER_NE_TRGEOMETRY_TRGEOMETRY: 'EVER_NE_TRGEOMETRY_TRGEOMETRY' | 'ever_ne_trgeometry_trgeometry'; +ALWAYS_NE_TRGEOMETRY_TRGEOMETRY: 'ALWAYS_NE_TRGEOMETRY_TRGEOMETRY' | 'always_ne_trgeometry_trgeometry'; +NAD_TRGEOMETRY_TRGEOMETRY: 'NAD_TRGEOMETRY_TRGEOMETRY' | 'nad_trgeometry_trgeometry'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 2eeeb29e3f..0f01c34eab 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -470,6 +470,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -10486,6 +10491,91 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(AlwaysNeGeoTrgeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); } /* END CODEGEN PARSER GLUE: ALWAYS_NE_GEO_TRGEOMETRY */ + case AntlrSQLParser::EVER_EQ_TRGEOMETRY_TRGEOMETRY: { + PRECONDITION(ctx->functionParam().size() == 10, + "EverEqTrgeometryTrgeometry requires 10 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + auto arg8 = visit(ctx->functionParam(8)).as(); + auto arg9 = visit(ctx->functionParam(9)).as(); + return LogicalFunction(EverEqTrgeometryTrgeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8), std::move(arg9))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_TRGEOMETRY_TRGEOMETRY */ + case AntlrSQLParser::ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY: { + PRECONDITION(ctx->functionParam().size() == 10, + "AlwaysEqTrgeometryTrgeometry requires 10 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + auto arg8 = visit(ctx->functionParam(8)).as(); + auto arg9 = visit(ctx->functionParam(9)).as(); + return LogicalFunction(AlwaysEqTrgeometryTrgeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8), std::move(arg9))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY */ + case AntlrSQLParser::EVER_NE_TRGEOMETRY_TRGEOMETRY: { + PRECONDITION(ctx->functionParam().size() == 10, + "EverNeTrgeometryTrgeometry requires 10 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + auto arg8 = visit(ctx->functionParam(8)).as(); + auto arg9 = visit(ctx->functionParam(9)).as(); + return LogicalFunction(EverNeTrgeometryTrgeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8), std::move(arg9))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_TRGEOMETRY_TRGEOMETRY */ + case AntlrSQLParser::ALWAYS_NE_TRGEOMETRY_TRGEOMETRY: { + PRECONDITION(ctx->functionParam().size() == 10, + "AlwaysNeTrgeometryTrgeometry requires 10 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + auto arg8 = visit(ctx->functionParam(8)).as(); + auto arg9 = visit(ctx->functionParam(9)).as(); + return LogicalFunction(AlwaysNeTrgeometryTrgeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8), std::move(arg9))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TRGEOMETRY_TRGEOMETRY */ + case AntlrSQLParser::NAD_TRGEOMETRY_TRGEOMETRY: { + PRECONDITION(ctx->functionParam().size() == 10, + "NadTrgeometryTrgeometry requires 10 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + auto arg7 = visit(ctx->functionParam(7)).as(); + auto arg8 = visit(ctx->functionParam(8)).as(); + auto arg9 = visit(ctx->functionParam(9)).as(); + return LogicalFunction(NadTrgeometryTrgeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8), std::move(arg9))); + } + /* END CODEGEN PARSER GLUE: NAD_TRGEOMETRY_TRGEOMETRY */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 5d81835778cb735901501664b1bb904798592810 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 16:52:11 +0200 Subject: [PATCH 72/86] feat(meos): add TPCPOINT per-event spatial predicate NES operators (W124) Wires two tpcpoint-vs-geometry per-event scalar operators using a 3-arg pattern (pt_hexwkb:VARCHAR, ts:UINT64, tgt_wkt:VARCHAR) -> FLOAT64. Each physical function deserializes the pcpoint from hex-WKB via pcpoint_from_hexwkb, wraps it as a tpcpoint instant via tpointcloudinst_make, and evaluates the geometry target built from WKT. Operators: EINTERSECTS_TPCPOINT_GEO (returns 0.0/1.0) and NAD_TPCPOINT_GEO (returns nearest-approach distance). --- .../EintersectsTpcpointGeoLogicalFunction.hpp | 48 +++++++++ .../Meos/NadTpcpointGeoLogicalFunction.hpp | 48 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../EintersectsTpcpointGeoLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/NadTpcpointGeoLogicalFunction.cpp | 102 ++++++++++++++++++ ...EintersectsTpcpointGeoPhysicalFunction.hpp | 32 ++++++ .../Meos/NadTpcpointGeoPhysicalFunction.hpp | 32 ++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + ...EintersectsTpcpointGeoPhysicalFunction.cpp | 86 +++++++++++++++ .../Meos/NadTpcpointGeoPhysicalFunction.cpp | 86 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 4 +- .../src/AntlrSQLQueryPlanCreator.cpp | 22 ++++ 12 files changed, 565 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/EintersectsTpcpointGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/NadTpcpointGeoLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/EintersectsTpcpointGeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/NadTpcpointGeoLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/EintersectsTpcpointGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/NadTpcpointGeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/EintersectsTpcpointGeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/NadTpcpointGeoPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/EintersectsTpcpointGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EintersectsTpcpointGeoLogicalFunction.hpp new file mode 100644 index 0000000000..cc774ce64f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EintersectsTpcpointGeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tpcpoint instant position intersects the geometry. + */ +class EintersectsTpcpointGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EintersectsTpcpointGeo"; + + EintersectsTpcpointGeoLogicalFunction(LogicalFunction pt_hexwkb, LogicalFunction ts, LogicalFunction tgt_wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/NadTpcpointGeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/NadTpcpointGeoLogicalFunction.hpp new file mode 100644 index 0000000000..d02a95fac3 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/NadTpcpointGeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nearest-approach distance between a tpcpoint instant and a geometry. + */ +class NadTpcpointGeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "NadTpcpointGeo"; + + NadTpcpointGeoLogicalFunction(LogicalFunction pt_hexwkb, LogicalFunction ts, LogicalFunction tgt_wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index d4ada48eac..684831de40 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -424,6 +424,8 @@ add_plugin(AlwaysEqTrgeometryTrgeometry LogicalFunction nes-logical-operators Al add_plugin(EverNeTrgeometryTrgeometry LogicalFunction nes-logical-operators EverNeTrgeometryTrgeometryLogicalFunction.cpp) add_plugin(AlwaysNeTrgeometryTrgeometry LogicalFunction nes-logical-operators AlwaysNeTrgeometryTrgeometryLogicalFunction.cpp) add_plugin(NadTrgeometryTrgeometry LogicalFunction nes-logical-operators NadTrgeometryTrgeometryLogicalFunction.cpp) +add_plugin(EintersectsTpcpointGeo LogicalFunction nes-logical-operators EintersectsTpcpointGeoLogicalFunction.cpp) +add_plugin(NadTpcpointGeo LogicalFunction nes-logical-operators NadTpcpointGeoLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EintersectsTpcpointGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EintersectsTpcpointGeoLogicalFunction.cpp new file mode 100644 index 0000000000..638fde37ec --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EintersectsTpcpointGeoLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EintersectsTpcpointGeoLogicalFunction::EintersectsTpcpointGeoLogicalFunction(LogicalFunction pt_hexwkb, LogicalFunction ts, LogicalFunction tgt_wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(pt_hexwkb)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(tgt_wkt)); +} + +DataType EintersectsTpcpointGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EintersectsTpcpointGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EintersectsTpcpointGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EintersectsTpcpointGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "EintersectsTpcpointGeoLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EintersectsTpcpointGeoLogicalFunction::getType() const { return NAME; } + +bool EintersectsTpcpointGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EintersectsTpcpointGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EintersectsTpcpointGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "pt_hexwkb must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::VARSIZED), "tgt_wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction EintersectsTpcpointGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEintersectsTpcpointGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EintersectsTpcpointGeoLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return EintersectsTpcpointGeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/NadTpcpointGeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/NadTpcpointGeoLogicalFunction.cpp new file mode 100644 index 0000000000..b43ef28fda --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/NadTpcpointGeoLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +NadTpcpointGeoLogicalFunction::NadTpcpointGeoLogicalFunction(LogicalFunction pt_hexwkb, LogicalFunction ts, LogicalFunction tgt_wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(pt_hexwkb)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(tgt_wkt)); +} + +DataType NadTpcpointGeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction NadTpcpointGeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector NadTpcpointGeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction NadTpcpointGeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "NadTpcpointGeoLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view NadTpcpointGeoLogicalFunction::getType() const { return NAME; } + +bool NadTpcpointGeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string NadTpcpointGeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction NadTpcpointGeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "pt_hexwkb must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::VARSIZED), "tgt_wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction NadTpcpointGeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterNadTpcpointGeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "NadTpcpointGeoLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return NadTpcpointGeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EintersectsTpcpointGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EintersectsTpcpointGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..c13b745146 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EintersectsTpcpointGeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EintersectsTpcpointGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EintersectsTpcpointGeoPhysicalFunction(PhysicalFunction pt_hexwkb, PhysicalFunction ts, PhysicalFunction tgt_wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/NadTpcpointGeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/NadTpcpointGeoPhysicalFunction.hpp new file mode 100644 index 0000000000..77b3a1f03d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/NadTpcpointGeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class NadTpcpointGeoPhysicalFunction : public PhysicalFunctionConcept { +public: + NadTpcpointGeoPhysicalFunction(PhysicalFunction pt_hexwkb, PhysicalFunction ts, PhysicalFunction tgt_wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 74c4b79187..51c2891c4e 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -423,6 +423,8 @@ add_plugin(AlwaysEqTrgeometryTrgeometry PhysicalFunction nes-physical-operators add_plugin(EverNeTrgeometryTrgeometry PhysicalFunction nes-physical-operators EverNeTrgeometryTrgeometryPhysicalFunction.cpp) add_plugin(AlwaysNeTrgeometryTrgeometry PhysicalFunction nes-physical-operators AlwaysNeTrgeometryTrgeometryPhysicalFunction.cpp) add_plugin(NadTrgeometryTrgeometry PhysicalFunction nes-physical-operators NadTrgeometryTrgeometryPhysicalFunction.cpp) +add_plugin(EintersectsTpcpointGeo PhysicalFunction nes-physical-operators EintersectsTpcpointGeoPhysicalFunction.cpp) +add_plugin(NadTpcpointGeo PhysicalFunction nes-physical-operators NadTpcpointGeoPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EintersectsTpcpointGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EintersectsTpcpointGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..bd67ef95d6 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EintersectsTpcpointGeoPhysicalFunction.cpp @@ -0,0 +1,86 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +EintersectsTpcpointGeoPhysicalFunction::EintersectsTpcpointGeoPhysicalFunction(PhysicalFunction pt_hexwkb, PhysicalFunction ts, PhysicalFunction tgt_wkt) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(pt_hexwkb)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(tgt_wkt)); +} + +VarVal EintersectsTpcpointGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto pt_hexwkb = paramFns[0].execute(record, arena); + auto ts = paramFns[1].execute(record, arena).cast(); + auto tgt_wkt = paramFns[2].execute(record, arena); + const auto result = nautilus::invoke( + +[](const char* pt_hexwkb, uint32_t pt_len, uint64_t ts, const char* tgt_wkt, uint32_t tgt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* hs = (char*)malloc(pt_len + 1); + memcpy(hs, pt_hexwkb, pt_len); hs[pt_len] = '\0'; + Pcpoint* pt = pcpoint_from_hexwkb(hs); free(hs); + if (!pt) return 0.0; + TInstant* inst = tpointcloudinst_make(pt, (TimestampTz)ts); + free(pt); + if (!inst) return 0.0; + char* gs_str = (char*)malloc(tgt_len + 1); + memcpy(gs_str, tgt_wkt, tgt_len); gs_str[tgt_len] = '\0'; + GSERIALIZED* gs = geom_in(gs_str, -1); free(gs_str); + if (!gs) { free(inst); return 0.0; } + bool r = eintersects_tpcpoint_geo((Temporal*)inst, gs); + free(inst); free(gs); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + pt_hexwkb, ts, tgt_wkt); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEintersectsTpcpointGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EintersectsTpcpointGeoPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EintersectsTpcpointGeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/NadTpcpointGeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/NadTpcpointGeoPhysicalFunction.cpp new file mode 100644 index 0000000000..af66f8258d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/NadTpcpointGeoPhysicalFunction.cpp @@ -0,0 +1,86 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +#include +} + +namespace NES { + +NadTpcpointGeoPhysicalFunction::NadTpcpointGeoPhysicalFunction(PhysicalFunction pt_hexwkb, PhysicalFunction ts, PhysicalFunction tgt_wkt) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(pt_hexwkb)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(tgt_wkt)); +} + +VarVal NadTpcpointGeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto pt_hexwkb = paramFns[0].execute(record, arena); + auto ts = paramFns[1].execute(record, arena).cast(); + auto tgt_wkt = paramFns[2].execute(record, arena); + const auto result = nautilus::invoke( + +[](const char* pt_hexwkb, uint32_t pt_len, uint64_t ts, const char* tgt_wkt, uint32_t tgt_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* hs = (char*)malloc(pt_len + 1); + memcpy(hs, pt_hexwkb, pt_len); hs[pt_len] = '\0'; + Pcpoint* pt = pcpoint_from_hexwkb(hs); free(hs); + if (!pt) return 0.0; + TInstant* inst = tpointcloudinst_make(pt, (TimestampTz)ts); + free(pt); + if (!inst) return 0.0; + char* gs_str = (char*)malloc(tgt_len + 1); + memcpy(gs_str, tgt_wkt, tgt_len); gs_str[tgt_len] = '\0'; + GSERIALIZED* gs = geom_in(gs_str, -1); free(gs_str); + if (!gs) { free(inst); return 0.0; } + double r = nad_tpcpoint_geo((Temporal*)inst, gs); + free(inst); free(gs); + return r; + } catch (const std::exception&) { return 0.0; } + }, + pt_hexwkb, ts, tgt_wkt); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterNadTpcpointGeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "NadTpcpointGeoPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return NadTpcpointGeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 0941f3efb3..a6a2b4b706 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -894,6 +894,8 @@ ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY: 'ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY' | 'always_eq_ EVER_NE_TRGEOMETRY_TRGEOMETRY: 'EVER_NE_TRGEOMETRY_TRGEOMETRY' | 'ever_ne_trgeometry_trgeometry'; ALWAYS_NE_TRGEOMETRY_TRGEOMETRY: 'ALWAYS_NE_TRGEOMETRY_TRGEOMETRY' | 'always_ne_trgeometry_trgeometry'; NAD_TRGEOMETRY_TRGEOMETRY: 'NAD_TRGEOMETRY_TRGEOMETRY' | 'nad_trgeometry_trgeometry'; +EINTERSECTS_TPCPOINT_GEO: 'EINTERSECTS_TPCPOINT_GEO' | 'eintersects_tpcpoint_geo'; +NAD_TPCPOINT_GEO: 'NAD_TPCPOINT_GEO' | 'nad_tpcpoint_geo'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 0f01c34eab..a4ff2c77c5 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -475,6 +475,8 @@ #include #include #include +#include +#include #include #include #include @@ -10576,6 +10578,26 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(NadTrgeometryTrgeometryLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6), std::move(arg7), std::move(arg8), std::move(arg9))); } /* END CODEGEN PARSER GLUE: NAD_TRGEOMETRY_TRGEOMETRY */ + case AntlrSQLParser::EINTERSECTS_TPCPOINT_GEO: { + PRECONDITION(ctx->functionParam().size() == 3, + "EintersectsTpcpointGeo requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(EintersectsTpcpointGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: EINTERSECTS_TPCPOINT_GEO */ + case AntlrSQLParser::NAD_TPCPOINT_GEO: { + PRECONDITION(ctx->functionParam().size() == 3, + "NadTpcpointGeo requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(NadTpcpointGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: NAD_TPCPOINT_GEO */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 2106beacc9716fdb83c273e5e979c30fa37336ca Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 17:43:13 +0200 Subject: [PATCH 73/86] feat(meos): add QUADBIN static cell NES operators (W125) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wires seven quadbin cell operators across four patterns: QUADBIN_POINT_TO_CELL (lon/lat/res→VARCHAR), QUADBIN_IS_VALID_CELL/GET_RESOLUTION/CELL_AREA (cell→FLOAT64), QUADBIN_CELL_TO_QUADKEY (cell→VARCHAR), QUADBIN_CELL_TO_PARENT (cell/res→VARCHAR), QUADBIN_TILE_TO_CELL (x/y/z→VARCHAR). Cell values are UINT64; VARCHAR results use quadbin_index_to_string or quadbin_cell_to_quadkey serialization. --- .../Meos/QuadbinCellAreaLogicalFunction.hpp | 48 ++++++++ .../QuadbinCellToParentLogicalFunction.hpp | 48 ++++++++ .../QuadbinCellToQuadkeyLogicalFunction.hpp | 48 ++++++++ .../QuadbinGetResolutionLogicalFunction.hpp | 48 ++++++++ .../QuadbinIsValidCellLogicalFunction.hpp | 48 ++++++++ .../QuadbinPointToCellLogicalFunction.hpp | 48 ++++++++ .../Meos/QuadbinTileToCellLogicalFunction.hpp | 48 ++++++++ .../src/Functions/Meos/CMakeLists.txt | 7 ++ .../Meos/QuadbinCellAreaLogicalFunction.cpp | 95 ++++++++++++++++ .../QuadbinCellToParentLogicalFunction.cpp | 99 +++++++++++++++++ .../QuadbinCellToQuadkeyLogicalFunction.cpp | 95 ++++++++++++++++ .../QuadbinGetResolutionLogicalFunction.cpp | 95 ++++++++++++++++ .../QuadbinIsValidCellLogicalFunction.cpp | 95 ++++++++++++++++ .../QuadbinPointToCellLogicalFunction.cpp | 103 ++++++++++++++++++ .../Meos/QuadbinTileToCellLogicalFunction.cpp | 103 ++++++++++++++++++ .../Meos/QuadbinCellAreaPhysicalFunction.hpp | 32 ++++++ .../QuadbinCellToParentPhysicalFunction.hpp | 32 ++++++ .../QuadbinCellToQuadkeyPhysicalFunction.hpp | 32 ++++++ .../QuadbinGetResolutionPhysicalFunction.hpp | 32 ++++++ .../QuadbinIsValidCellPhysicalFunction.hpp | 32 ++++++ .../QuadbinPointToCellPhysicalFunction.hpp | 32 ++++++ .../QuadbinTileToCellPhysicalFunction.hpp | 32 ++++++ .../src/Functions/Meos/CMakeLists.txt | 7 ++ .../Meos/QuadbinCellAreaPhysicalFunction.cpp | 66 +++++++++++ .../QuadbinCellToParentPhysicalFunction.cpp | 82 ++++++++++++++ .../QuadbinCellToQuadkeyPhysicalFunction.cpp | 77 +++++++++++++ .../QuadbinGetResolutionPhysicalFunction.cpp | 66 +++++++++++ .../QuadbinIsValidCellPhysicalFunction.cpp | 66 +++++++++++ .../QuadbinPointToCellPhysicalFunction.cpp | 85 +++++++++++++++ .../QuadbinTileToCellPhysicalFunction.cpp | 85 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 9 +- .../src/AntlrSQLQueryPlanCreator.cpp | 68 ++++++++++++ 32 files changed, 1862 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/QuadbinCellAreaLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/QuadbinCellToParentLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/QuadbinCellToQuadkeyLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/QuadbinGetResolutionLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/QuadbinIsValidCellLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/QuadbinPointToCellLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/QuadbinTileToCellLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/QuadbinCellAreaLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/QuadbinCellToParentLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/QuadbinCellToQuadkeyLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/QuadbinGetResolutionLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/QuadbinIsValidCellLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/QuadbinPointToCellLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/QuadbinTileToCellLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/QuadbinCellAreaPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/QuadbinCellToParentPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/QuadbinCellToQuadkeyPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/QuadbinGetResolutionPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/QuadbinIsValidCellPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/QuadbinPointToCellPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/QuadbinTileToCellPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/QuadbinCellAreaPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/QuadbinCellToParentPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/QuadbinCellToQuadkeyPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/QuadbinGetResolutionPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/QuadbinIsValidCellPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/QuadbinPointToCellPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/QuadbinTileToCellPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/QuadbinCellAreaLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/QuadbinCellAreaLogicalFunction.hpp new file mode 100644 index 0000000000..56d79731ff --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/QuadbinCellAreaLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns a FLOAT64 scalar for a quadbin cell. NES token: QUADBIN_CELL_AREA. + */ +class QuadbinCellAreaLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "QuadbinCellArea"; + + QuadbinCellAreaLogicalFunction(LogicalFunction cell); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/QuadbinCellToParentLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/QuadbinCellToParentLogicalFunction.hpp new file mode 100644 index 0000000000..57abe70a7b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/QuadbinCellToParentLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns a VARCHAR for a quadbin cell. NES token: QUADBIN_CELL_TO_PARENT. + */ +class QuadbinCellToParentLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "QuadbinCellToParent"; + + QuadbinCellToParentLogicalFunction(LogicalFunction cell, LogicalFunction res); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/QuadbinCellToQuadkeyLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/QuadbinCellToQuadkeyLogicalFunction.hpp new file mode 100644 index 0000000000..9e5a12bcb7 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/QuadbinCellToQuadkeyLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns a VARCHAR for a quadbin cell. NES token: QUADBIN_CELL_TO_QUADKEY. + */ +class QuadbinCellToQuadkeyLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "QuadbinCellToQuadkey"; + + QuadbinCellToQuadkeyLogicalFunction(LogicalFunction cell); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/QuadbinGetResolutionLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/QuadbinGetResolutionLogicalFunction.hpp new file mode 100644 index 0000000000..b332f289fe --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/QuadbinGetResolutionLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns a FLOAT64 scalar for a quadbin cell. NES token: QUADBIN_GET_RESOLUTION. + */ +class QuadbinGetResolutionLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "QuadbinGetResolution"; + + QuadbinGetResolutionLogicalFunction(LogicalFunction cell); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/QuadbinIsValidCellLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/QuadbinIsValidCellLogicalFunction.hpp new file mode 100644 index 0000000000..be48e755b9 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/QuadbinIsValidCellLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns a FLOAT64 scalar for a quadbin cell. NES token: QUADBIN_IS_VALID_CELL. + */ +class QuadbinIsValidCellLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "QuadbinIsValidCell"; + + QuadbinIsValidCellLogicalFunction(LogicalFunction cell); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/QuadbinPointToCellLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/QuadbinPointToCellLogicalFunction.hpp new file mode 100644 index 0000000000..6af0e0da1d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/QuadbinPointToCellLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns a VARCHAR for a quadbin cell. NES token: QUADBIN_POINT_TO_CELL. + */ +class QuadbinPointToCellLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "QuadbinPointToCell"; + + QuadbinPointToCellLogicalFunction(LogicalFunction lon, LogicalFunction lat, LogicalFunction res); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/QuadbinTileToCellLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/QuadbinTileToCellLogicalFunction.hpp new file mode 100644 index 0000000000..d655955c70 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/QuadbinTileToCellLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns a VARCHAR for a quadbin cell. NES token: QUADBIN_TILE_TO_CELL. + */ +class QuadbinTileToCellLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "QuadbinTileToCell"; + + QuadbinTileToCellLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction z); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 684831de40..8b81ca36ca 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -426,6 +426,13 @@ add_plugin(AlwaysNeTrgeometryTrgeometry LogicalFunction nes-logical-operators Al add_plugin(NadTrgeometryTrgeometry LogicalFunction nes-logical-operators NadTrgeometryTrgeometryLogicalFunction.cpp) add_plugin(EintersectsTpcpointGeo LogicalFunction nes-logical-operators EintersectsTpcpointGeoLogicalFunction.cpp) add_plugin(NadTpcpointGeo LogicalFunction nes-logical-operators NadTpcpointGeoLogicalFunction.cpp) +add_plugin(QuadbinPointToCell LogicalFunction nes-logical-operators QuadbinPointToCellLogicalFunction.cpp) +add_plugin(QuadbinIsValidCell LogicalFunction nes-logical-operators QuadbinIsValidCellLogicalFunction.cpp) +add_plugin(QuadbinGetResolution LogicalFunction nes-logical-operators QuadbinGetResolutionLogicalFunction.cpp) +add_plugin(QuadbinCellArea LogicalFunction nes-logical-operators QuadbinCellAreaLogicalFunction.cpp) +add_plugin(QuadbinCellToQuadkey LogicalFunction nes-logical-operators QuadbinCellToQuadkeyLogicalFunction.cpp) +add_plugin(QuadbinCellToParent LogicalFunction nes-logical-operators QuadbinCellToParentLogicalFunction.cpp) +add_plugin(QuadbinTileToCell LogicalFunction nes-logical-operators QuadbinTileToCellLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/QuadbinCellAreaLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/QuadbinCellAreaLogicalFunction.cpp new file mode 100644 index 0000000000..4e1828ac1b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/QuadbinCellAreaLogicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +QuadbinCellAreaLogicalFunction::QuadbinCellAreaLogicalFunction(LogicalFunction cell) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(cell)); +} + +DataType QuadbinCellAreaLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction QuadbinCellAreaLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector QuadbinCellAreaLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction QuadbinCellAreaLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "QuadbinCellAreaLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view QuadbinCellAreaLogicalFunction::getType() const { return NAME; } + +bool QuadbinCellAreaLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string QuadbinCellAreaLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction QuadbinCellAreaLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + c.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + return withChildren(c); +} + +SerializableFunction QuadbinCellAreaLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterQuadbinCellAreaLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "QuadbinCellAreaLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return QuadbinCellAreaLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/QuadbinCellToParentLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/QuadbinCellToParentLogicalFunction.cpp new file mode 100644 index 0000000000..d2b9d2f050 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/QuadbinCellToParentLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +QuadbinCellToParentLogicalFunction::QuadbinCellToParentLogicalFunction(LogicalFunction cell, LogicalFunction res) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(cell)); + parameters.push_back(std::move(res)); +} + +DataType QuadbinCellToParentLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction QuadbinCellToParentLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector QuadbinCellToParentLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction QuadbinCellToParentLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "QuadbinCellToParentLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view QuadbinCellToParentLogicalFunction::getType() const { return NAME; } + +bool QuadbinCellToParentLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string QuadbinCellToParentLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction QuadbinCellToParentLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "res must be UINT64"); + return withChildren(c); +} + +SerializableFunction QuadbinCellToParentLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterQuadbinCellToParentLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "QuadbinCellToParentLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return QuadbinCellToParentLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/QuadbinCellToQuadkeyLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/QuadbinCellToQuadkeyLogicalFunction.cpp new file mode 100644 index 0000000000..547d5861cc --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/QuadbinCellToQuadkeyLogicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +QuadbinCellToQuadkeyLogicalFunction::QuadbinCellToQuadkeyLogicalFunction(LogicalFunction cell) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(1); + parameters.push_back(std::move(cell)); +} + +DataType QuadbinCellToQuadkeyLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction QuadbinCellToQuadkeyLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector QuadbinCellToQuadkeyLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction QuadbinCellToQuadkeyLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "QuadbinCellToQuadkeyLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view QuadbinCellToQuadkeyLogicalFunction::getType() const { return NAME; } + +bool QuadbinCellToQuadkeyLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string QuadbinCellToQuadkeyLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction QuadbinCellToQuadkeyLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + c.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + return withChildren(c); +} + +SerializableFunction QuadbinCellToQuadkeyLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterQuadbinCellToQuadkeyLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "QuadbinCellToQuadkeyLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return QuadbinCellToQuadkeyLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/QuadbinGetResolutionLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/QuadbinGetResolutionLogicalFunction.cpp new file mode 100644 index 0000000000..c8bc6be072 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/QuadbinGetResolutionLogicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +QuadbinGetResolutionLogicalFunction::QuadbinGetResolutionLogicalFunction(LogicalFunction cell) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(cell)); +} + +DataType QuadbinGetResolutionLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction QuadbinGetResolutionLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector QuadbinGetResolutionLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction QuadbinGetResolutionLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "QuadbinGetResolutionLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view QuadbinGetResolutionLogicalFunction::getType() const { return NAME; } + +bool QuadbinGetResolutionLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string QuadbinGetResolutionLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction QuadbinGetResolutionLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + c.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + return withChildren(c); +} + +SerializableFunction QuadbinGetResolutionLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterQuadbinGetResolutionLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "QuadbinGetResolutionLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return QuadbinGetResolutionLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/QuadbinIsValidCellLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/QuadbinIsValidCellLogicalFunction.cpp new file mode 100644 index 0000000000..fee9e32794 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/QuadbinIsValidCellLogicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +QuadbinIsValidCellLogicalFunction::QuadbinIsValidCellLogicalFunction(LogicalFunction cell) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(cell)); +} + +DataType QuadbinIsValidCellLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction QuadbinIsValidCellLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector QuadbinIsValidCellLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction QuadbinIsValidCellLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "QuadbinIsValidCellLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view QuadbinIsValidCellLogicalFunction::getType() const { return NAME; } + +bool QuadbinIsValidCellLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string QuadbinIsValidCellLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction QuadbinIsValidCellLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + c.emplace_back(parameters[0].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "cell must be UINT64"); + return withChildren(c); +} + +SerializableFunction QuadbinIsValidCellLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterQuadbinIsValidCellLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "QuadbinIsValidCellLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return QuadbinIsValidCellLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/QuadbinPointToCellLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/QuadbinPointToCellLogicalFunction.cpp new file mode 100644 index 0000000000..33311bcde9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/QuadbinPointToCellLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +QuadbinPointToCellLogicalFunction::QuadbinPointToCellLogicalFunction(LogicalFunction lon, LogicalFunction lat, LogicalFunction res) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(3); + parameters.push_back(std::move(lon)); + parameters.push_back(std::move(lat)); + parameters.push_back(std::move(res)); +} + +DataType QuadbinPointToCellLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction QuadbinPointToCellLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector QuadbinPointToCellLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction QuadbinPointToCellLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "QuadbinPointToCellLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view QuadbinPointToCellLogicalFunction::getType() const { return NAME; } + +bool QuadbinPointToCellLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string QuadbinPointToCellLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction QuadbinPointToCellLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "res must be UINT64"); + return withChildren(c); +} + +SerializableFunction QuadbinPointToCellLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterQuadbinPointToCellLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "QuadbinPointToCellLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return QuadbinPointToCellLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/QuadbinTileToCellLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/QuadbinTileToCellLogicalFunction.cpp new file mode 100644 index 0000000000..334bd4a162 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/QuadbinTileToCellLogicalFunction.cpp @@ -0,0 +1,103 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +QuadbinTileToCellLogicalFunction::QuadbinTileToCellLogicalFunction(LogicalFunction x, LogicalFunction y, LogicalFunction z) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(3); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(z)); +} + +DataType QuadbinTileToCellLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction QuadbinTileToCellLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector QuadbinTileToCellLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction QuadbinTileToCellLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "QuadbinTileToCellLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view QuadbinTileToCellLogicalFunction::getType() const { return NAME; } + +bool QuadbinTileToCellLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string QuadbinTileToCellLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction QuadbinTileToCellLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + c.emplace_back(parameters[0].withInferredDataType(schema)); + c.emplace_back(parameters[1].withInferredDataType(schema)); + c.emplace_back(parameters[2].withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "x must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "y must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "z must be UINT64"); + return withChildren(c); +} + +SerializableFunction QuadbinTileToCellLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterQuadbinTileToCellLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "QuadbinTileToCellLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return QuadbinTileToCellLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/QuadbinCellAreaPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/QuadbinCellAreaPhysicalFunction.hpp new file mode 100644 index 0000000000..796b3fea82 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/QuadbinCellAreaPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class QuadbinCellAreaPhysicalFunction : public PhysicalFunctionConcept { +public: + QuadbinCellAreaPhysicalFunction(PhysicalFunction cell); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/QuadbinCellToParentPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/QuadbinCellToParentPhysicalFunction.hpp new file mode 100644 index 0000000000..1f8f5d9545 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/QuadbinCellToParentPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class QuadbinCellToParentPhysicalFunction : public PhysicalFunctionConcept { +public: + QuadbinCellToParentPhysicalFunction(PhysicalFunction cell, PhysicalFunction res); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/QuadbinCellToQuadkeyPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/QuadbinCellToQuadkeyPhysicalFunction.hpp new file mode 100644 index 0000000000..69b7da24f4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/QuadbinCellToQuadkeyPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class QuadbinCellToQuadkeyPhysicalFunction : public PhysicalFunctionConcept { +public: + QuadbinCellToQuadkeyPhysicalFunction(PhysicalFunction cell); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/QuadbinGetResolutionPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/QuadbinGetResolutionPhysicalFunction.hpp new file mode 100644 index 0000000000..c456176fae --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/QuadbinGetResolutionPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class QuadbinGetResolutionPhysicalFunction : public PhysicalFunctionConcept { +public: + QuadbinGetResolutionPhysicalFunction(PhysicalFunction cell); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/QuadbinIsValidCellPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/QuadbinIsValidCellPhysicalFunction.hpp new file mode 100644 index 0000000000..b33082239a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/QuadbinIsValidCellPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class QuadbinIsValidCellPhysicalFunction : public PhysicalFunctionConcept { +public: + QuadbinIsValidCellPhysicalFunction(PhysicalFunction cell); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/QuadbinPointToCellPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/QuadbinPointToCellPhysicalFunction.hpp new file mode 100644 index 0000000000..8b20f0ef23 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/QuadbinPointToCellPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class QuadbinPointToCellPhysicalFunction : public PhysicalFunctionConcept { +public: + QuadbinPointToCellPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, PhysicalFunction res); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/QuadbinTileToCellPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/QuadbinTileToCellPhysicalFunction.hpp new file mode 100644 index 0000000000..02ac96c13f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/QuadbinTileToCellPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class QuadbinTileToCellPhysicalFunction : public PhysicalFunctionConcept { +public: + QuadbinTileToCellPhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction z); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 51c2891c4e..53f465f9d5 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -425,6 +425,13 @@ add_plugin(AlwaysNeTrgeometryTrgeometry PhysicalFunction nes-physical-operators add_plugin(NadTrgeometryTrgeometry PhysicalFunction nes-physical-operators NadTrgeometryTrgeometryPhysicalFunction.cpp) add_plugin(EintersectsTpcpointGeo PhysicalFunction nes-physical-operators EintersectsTpcpointGeoPhysicalFunction.cpp) add_plugin(NadTpcpointGeo PhysicalFunction nes-physical-operators NadTpcpointGeoPhysicalFunction.cpp) +add_plugin(QuadbinPointToCell PhysicalFunction nes-physical-operators QuadbinPointToCellPhysicalFunction.cpp) +add_plugin(QuadbinIsValidCell PhysicalFunction nes-physical-operators QuadbinIsValidCellPhysicalFunction.cpp) +add_plugin(QuadbinGetResolution PhysicalFunction nes-physical-operators QuadbinGetResolutionPhysicalFunction.cpp) +add_plugin(QuadbinCellArea PhysicalFunction nes-physical-operators QuadbinCellAreaPhysicalFunction.cpp) +add_plugin(QuadbinCellToQuadkey PhysicalFunction nes-physical-operators QuadbinCellToQuadkeyPhysicalFunction.cpp) +add_plugin(QuadbinCellToParent PhysicalFunction nes-physical-operators QuadbinCellToParentPhysicalFunction.cpp) +add_plugin(QuadbinTileToCell PhysicalFunction nes-physical-operators QuadbinTileToCellPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/QuadbinCellAreaPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/QuadbinCellAreaPhysicalFunction.cpp new file mode 100644 index 0000000000..3289b28210 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/QuadbinCellAreaPhysicalFunction.cpp @@ -0,0 +1,66 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} +#include +#include + +namespace NES { + +QuadbinCellAreaPhysicalFunction::QuadbinCellAreaPhysicalFunction(PhysicalFunction cell) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(cell)); +} + +VarVal QuadbinCellAreaPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t cell) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + return quadbin_cell_area((Quadbin)cell); + } catch (const std::exception&) { return 0.0; } + }, + cell); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterQuadbinCellAreaPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "QuadbinCellAreaPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return QuadbinCellAreaPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/QuadbinCellToParentPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/QuadbinCellToParentPhysicalFunction.cpp new file mode 100644 index 0000000000..047bd77f29 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/QuadbinCellToParentPhysicalFunction.cpp @@ -0,0 +1,82 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} +#include +#include + +namespace NES { + +QuadbinCellToParentPhysicalFunction::QuadbinCellToParentPhysicalFunction(PhysicalFunction cell, PhysicalFunction res) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(cell)); + paramFns.push_back(std::move(res)); +} + +VarVal QuadbinCellToParentPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + auto res = paramFns[1].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 32; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](uint64_t cell, uint64_t res, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + Quadbin parent = quadbin_cell_to_parent((Quadbin)cell, (uint32_t)res); + if (parent == 0) return 0u; + char* s = quadbin_index_to_string(parent); + if (!s) return 0u; + uint32_t len = (uint32_t)strlen(s); + if (len > bufMax) len = bufMax; + memcpy(buf, s, len); + free(s); + return len; + } catch (const std::exception&) { return 0u; } + }, + cell, res, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterQuadbinCellToParentPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "QuadbinCellToParentPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return QuadbinCellToParentPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/QuadbinCellToQuadkeyPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/QuadbinCellToQuadkeyPhysicalFunction.cpp new file mode 100644 index 0000000000..a45874a29f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/QuadbinCellToQuadkeyPhysicalFunction.cpp @@ -0,0 +1,77 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} +#include +#include + +namespace NES { + +QuadbinCellToQuadkeyPhysicalFunction::QuadbinCellToQuadkeyPhysicalFunction(PhysicalFunction cell) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(cell)); +} + +VarVal QuadbinCellToQuadkeyPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 64; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](uint64_t cell, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s = quadbin_cell_to_quadkey((Quadbin)cell); + if (!s) return 0u; + uint32_t len = (uint32_t)strlen(s); + if (len > bufMax) len = bufMax; + memcpy(buf, s, len); + free(s); + return len; + } catch (const std::exception&) { return 0u; } + }, + cell, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterQuadbinCellToQuadkeyPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "QuadbinCellToQuadkeyPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return QuadbinCellToQuadkeyPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/QuadbinGetResolutionPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/QuadbinGetResolutionPhysicalFunction.cpp new file mode 100644 index 0000000000..0a725eeef1 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/QuadbinGetResolutionPhysicalFunction.cpp @@ -0,0 +1,66 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} +#include +#include + +namespace NES { + +QuadbinGetResolutionPhysicalFunction::QuadbinGetResolutionPhysicalFunction(PhysicalFunction cell) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(cell)); +} + +VarVal QuadbinGetResolutionPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t cell) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + return (double)quadbin_get_resolution((Quadbin)cell); + } catch (const std::exception&) { return 0.0; } + }, + cell); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterQuadbinGetResolutionPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "QuadbinGetResolutionPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return QuadbinGetResolutionPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/QuadbinIsValidCellPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/QuadbinIsValidCellPhysicalFunction.cpp new file mode 100644 index 0000000000..60360c76c4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/QuadbinIsValidCellPhysicalFunction.cpp @@ -0,0 +1,66 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} +#include +#include + +namespace NES { + +QuadbinIsValidCellPhysicalFunction::QuadbinIsValidCellPhysicalFunction(PhysicalFunction cell) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(cell)); +} + +VarVal QuadbinIsValidCellPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto cell = paramFns[0].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t cell) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + return quadbin_is_valid_cell((Quadbin)cell) ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + cell); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterQuadbinIsValidCellPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "QuadbinIsValidCellPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return QuadbinIsValidCellPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/QuadbinPointToCellPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/QuadbinPointToCellPhysicalFunction.cpp new file mode 100644 index 0000000000..eb526d8409 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/QuadbinPointToCellPhysicalFunction.cpp @@ -0,0 +1,85 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} +#include +#include + +namespace NES { + +QuadbinPointToCellPhysicalFunction::QuadbinPointToCellPhysicalFunction(PhysicalFunction lon, PhysicalFunction lat, PhysicalFunction res) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(lon)); + paramFns.push_back(std::move(lat)); + paramFns.push_back(std::move(res)); +} + +VarVal QuadbinPointToCellPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon = paramFns[0].execute(record, arena).cast(); + auto lat = paramFns[1].execute(record, arena).cast(); + auto res = paramFns[2].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 32; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](double lon, double lat, uint64_t res, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + Quadbin cell = quadbin_point_to_cell(lon, lat, (uint32_t)res); + if (cell == 0) return 0u; + char* s = quadbin_index_to_string(cell); + if (!s) return 0u; + uint32_t len = (uint32_t)strlen(s); + if (len > bufMax) len = bufMax; + memcpy(buf, s, len); + free(s); + return len; + } catch (const std::exception&) { return 0u; } + }, + lon, lat, res, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterQuadbinPointToCellPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "QuadbinPointToCellPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return QuadbinPointToCellPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/QuadbinTileToCellPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/QuadbinTileToCellPhysicalFunction.cpp new file mode 100644 index 0000000000..517bef3c93 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/QuadbinTileToCellPhysicalFunction.cpp @@ -0,0 +1,85 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} +#include +#include + +namespace NES { + +QuadbinTileToCellPhysicalFunction::QuadbinTileToCellPhysicalFunction(PhysicalFunction x, PhysicalFunction y, PhysicalFunction z) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(z)); +} + +VarVal QuadbinTileToCellPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto x = paramFns[0].execute(record, arena).cast(); + auto y = paramFns[1].execute(record, arena).cast(); + auto z = paramFns[2].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 32; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](uint64_t x, uint64_t y, uint64_t z, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + Quadbin cell = quadbin_tile_to_cell((uint32_t)x, (uint32_t)y, (uint32_t)z); + if (cell == 0) return 0u; + char* s = quadbin_index_to_string(cell); + if (!s) return 0u; + uint32_t len = (uint32_t)strlen(s); + if (len > bufMax) len = bufMax; + memcpy(buf, s, len); + free(s); + return len; + } catch (const std::exception&) { return 0u; } + }, + x, y, z, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterQuadbinTileToCellPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "QuadbinTileToCellPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return QuadbinTileToCellPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index a6a2b4b706..425bef310c 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -896,6 +896,13 @@ ALWAYS_NE_TRGEOMETRY_TRGEOMETRY: 'ALWAYS_NE_TRGEOMETRY_TRGEOMETRY' | 'always_ne_ NAD_TRGEOMETRY_TRGEOMETRY: 'NAD_TRGEOMETRY_TRGEOMETRY' | 'nad_trgeometry_trgeometry'; EINTERSECTS_TPCPOINT_GEO: 'EINTERSECTS_TPCPOINT_GEO' | 'eintersects_tpcpoint_geo'; NAD_TPCPOINT_GEO: 'NAD_TPCPOINT_GEO' | 'nad_tpcpoint_geo'; +QUADBIN_POINT_TO_CELL: 'QUADBIN_POINT_TO_CELL' | 'quadbin_point_to_cell'; +QUADBIN_IS_VALID_CELL: 'QUADBIN_IS_VALID_CELL' | 'quadbin_is_valid_cell'; +QUADBIN_GET_RESOLUTION: 'QUADBIN_GET_RESOLUTION' | 'quadbin_get_resolution'; +QUADBIN_CELL_AREA: 'QUADBIN_CELL_AREA' | 'quadbin_cell_area'; +QUADBIN_CELL_TO_QUADKEY: 'QUADBIN_CELL_TO_QUADKEY' | 'quadbin_cell_to_quadkey'; +QUADBIN_CELL_TO_PARENT: 'QUADBIN_CELL_TO_PARENT' | 'quadbin_cell_to_parent'; +QUADBIN_TILE_TO_CELL: 'QUADBIN_TILE_TO_CELL' | 'quadbin_tile_to_cell'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index a4ff2c77c5..e3a420f69d 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -477,6 +477,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -10598,6 +10605,67 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(NadTpcpointGeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); } /* END CODEGEN PARSER GLUE: NAD_TPCPOINT_GEO */ + case AntlrSQLParser::QUADBIN_POINT_TO_CELL: { + PRECONDITION(ctx->functionParam().size() == 3, + "QuadbinPointToCell requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(QuadbinPointToCellLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: QUADBIN_POINT_TO_CELL */ + case AntlrSQLParser::QUADBIN_IS_VALID_CELL: { + PRECONDITION(ctx->functionParam().size() == 1, + "QuadbinIsValidCell requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(QuadbinIsValidCellLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: QUADBIN_IS_VALID_CELL */ + case AntlrSQLParser::QUADBIN_GET_RESOLUTION: { + PRECONDITION(ctx->functionParam().size() == 1, + "QuadbinGetResolution requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(QuadbinGetResolutionLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: QUADBIN_GET_RESOLUTION */ + case AntlrSQLParser::QUADBIN_CELL_AREA: { + PRECONDITION(ctx->functionParam().size() == 1, + "QuadbinCellArea requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(QuadbinCellAreaLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: QUADBIN_CELL_AREA */ + case AntlrSQLParser::QUADBIN_CELL_TO_QUADKEY: { + PRECONDITION(ctx->functionParam().size() == 1, + "QuadbinCellToQuadkey requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(QuadbinCellToQuadkeyLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: QUADBIN_CELL_TO_QUADKEY */ + case AntlrSQLParser::QUADBIN_CELL_TO_PARENT: { + PRECONDITION(ctx->functionParam().size() == 2, + "QuadbinCellToParent requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(QuadbinCellToParentLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: QUADBIN_CELL_TO_PARENT */ + case AntlrSQLParser::QUADBIN_TILE_TO_CELL: { + PRECONDITION(ctx->functionParam().size() == 3, + "QuadbinTileToCell requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(QuadbinTileToCellLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: QUADBIN_TILE_TO_CELL */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 49255458ba1665b8f69121b97c17c4cc20e19f38 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 17:44:07 +0200 Subject: [PATCH 74/86] feat(meos): add TJSONB_JSONB per-event comparison NES operators (W126) Wires four tjsonb-vs-jsonb per-event scalar comparison operators using a 3-arg pattern (json_str:VARCHAR, ts:UINT64, target_json:VARCHAR) -> FLOAT64. Each physical function deserializes both JSON strings via jsonb_in, wraps the first as a tjsonb instant via tjsonbinst_make, then evaluates the comparison. Operators: EVER_EQ/ALWAYS_EQ/EVER_NE/ALWAYS_NE_TJSONB_JSONB (return 0.0/1.0). --- .../AlwaysEqTjsonbJsonbLogicalFunction.hpp | 48 +++++++++ .../AlwaysNeTjsonbJsonbLogicalFunction.hpp | 48 +++++++++ .../Meos/EverEqTjsonbJsonbLogicalFunction.hpp | 48 +++++++++ .../Meos/EverNeTjsonbJsonbLogicalFunction.hpp | 48 +++++++++ .../AlwaysEqTjsonbJsonbLogicalFunction.cpp | 102 ++++++++++++++++++ .../AlwaysNeTjsonbJsonbLogicalFunction.cpp | 102 ++++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/EverEqTjsonbJsonbLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/EverNeTjsonbJsonbLogicalFunction.cpp | 102 ++++++++++++++++++ .../AlwaysEqTjsonbJsonbPhysicalFunction.hpp | 32 ++++++ .../AlwaysNeTjsonbJsonbPhysicalFunction.hpp | 32 ++++++ .../EverEqTjsonbJsonbPhysicalFunction.hpp | 32 ++++++ .../EverNeTjsonbJsonbPhysicalFunction.hpp | 32 ++++++ .../AlwaysEqTjsonbJsonbPhysicalFunction.cpp | 85 +++++++++++++++ .../AlwaysNeTjsonbJsonbPhysicalFunction.cpp | 85 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../EverEqTjsonbJsonbPhysicalFunction.cpp | 85 +++++++++++++++ .../EverNeTjsonbJsonbPhysicalFunction.cpp | 85 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 44 ++++++++ 20 files changed, 1125 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTjsonbJsonbLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTjsonbJsonbLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTjsonbJsonbLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTjsonbJsonbLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTjsonbJsonbLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTjsonbJsonbLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTjsonbJsonbLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTjsonbJsonbLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTjsonbJsonbPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTjsonbJsonbPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTjsonbJsonbPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTjsonbJsonbPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTjsonbJsonbPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTjsonbJsonbPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTjsonbJsonbPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTjsonbJsonbPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTjsonbJsonbLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTjsonbJsonbLogicalFunction.hpp new file mode 100644 index 0000000000..e0427b9aba --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTjsonbJsonbLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tjsonb instant value always equals the target Jsonb. + */ +class AlwaysEqTjsonbJsonbLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTjsonbJsonb"; + + AlwaysEqTjsonbJsonbLogicalFunction(LogicalFunction json_str, LogicalFunction ts, LogicalFunction target_json); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTjsonbJsonbLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTjsonbJsonbLogicalFunction.hpp new file mode 100644 index 0000000000..05e7c81966 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTjsonbJsonbLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tjsonb instant value always differs from the target Jsonb. + */ +class AlwaysNeTjsonbJsonbLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTjsonbJsonb"; + + AlwaysNeTjsonbJsonbLogicalFunction(LogicalFunction json_str, LogicalFunction ts, LogicalFunction target_json); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTjsonbJsonbLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTjsonbJsonbLogicalFunction.hpp new file mode 100644 index 0000000000..aa53d1b34d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTjsonbJsonbLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tjsonb instant value ever equals the target Jsonb. + */ +class EverEqTjsonbJsonbLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTjsonbJsonb"; + + EverEqTjsonbJsonbLogicalFunction(LogicalFunction json_str, LogicalFunction ts, LogicalFunction target_json); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTjsonbJsonbLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTjsonbJsonbLogicalFunction.hpp new file mode 100644 index 0000000000..ed1cfd83af --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTjsonbJsonbLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the tjsonb instant value ever differs from the target Jsonb. + */ +class EverNeTjsonbJsonbLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTjsonbJsonb"; + + EverNeTjsonbJsonbLogicalFunction(LogicalFunction json_str, LogicalFunction ts, LogicalFunction target_json); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTjsonbJsonbLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTjsonbJsonbLogicalFunction.cpp new file mode 100644 index 0000000000..e842930882 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTjsonbJsonbLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTjsonbJsonbLogicalFunction::AlwaysEqTjsonbJsonbLogicalFunction(LogicalFunction json_str, LogicalFunction ts, LogicalFunction target_json) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(json_str)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(target_json)); +} + +DataType AlwaysEqTjsonbJsonbLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTjsonbJsonbLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTjsonbJsonbLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTjsonbJsonbLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "AlwaysEqTjsonbJsonbLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTjsonbJsonbLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTjsonbJsonbLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTjsonbJsonbLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqTjsonbJsonbLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "json_str must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::VARSIZED), "target_json must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction AlwaysEqTjsonbJsonbLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTjsonbJsonbLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysEqTjsonbJsonbLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return AlwaysEqTjsonbJsonbLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTjsonbJsonbLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTjsonbJsonbLogicalFunction.cpp new file mode 100644 index 0000000000..7d06e82ecc --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTjsonbJsonbLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTjsonbJsonbLogicalFunction::AlwaysNeTjsonbJsonbLogicalFunction(LogicalFunction json_str, LogicalFunction ts, LogicalFunction target_json) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(json_str)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(target_json)); +} + +DataType AlwaysNeTjsonbJsonbLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTjsonbJsonbLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTjsonbJsonbLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTjsonbJsonbLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "AlwaysNeTjsonbJsonbLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTjsonbJsonbLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTjsonbJsonbLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTjsonbJsonbLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeTjsonbJsonbLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "json_str must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::VARSIZED), "target_json must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction AlwaysNeTjsonbJsonbLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTjsonbJsonbLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "AlwaysNeTjsonbJsonbLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return AlwaysNeTjsonbJsonbLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 8b81ca36ca..77b24cdd84 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -433,6 +433,10 @@ add_plugin(QuadbinCellArea LogicalFunction nes-logical-operators QuadbinCellArea add_plugin(QuadbinCellToQuadkey LogicalFunction nes-logical-operators QuadbinCellToQuadkeyLogicalFunction.cpp) add_plugin(QuadbinCellToParent LogicalFunction nes-logical-operators QuadbinCellToParentLogicalFunction.cpp) add_plugin(QuadbinTileToCell LogicalFunction nes-logical-operators QuadbinTileToCellLogicalFunction.cpp) +add_plugin(EverEqTjsonbJsonb LogicalFunction nes-logical-operators EverEqTjsonbJsonbLogicalFunction.cpp) +add_plugin(AlwaysEqTjsonbJsonb LogicalFunction nes-logical-operators AlwaysEqTjsonbJsonbLogicalFunction.cpp) +add_plugin(EverNeTjsonbJsonb LogicalFunction nes-logical-operators EverNeTjsonbJsonbLogicalFunction.cpp) +add_plugin(AlwaysNeTjsonbJsonb LogicalFunction nes-logical-operators AlwaysNeTjsonbJsonbLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTjsonbJsonbLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTjsonbJsonbLogicalFunction.cpp new file mode 100644 index 0000000000..9afc80111a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTjsonbJsonbLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTjsonbJsonbLogicalFunction::EverEqTjsonbJsonbLogicalFunction(LogicalFunction json_str, LogicalFunction ts, LogicalFunction target_json) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(json_str)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(target_json)); +} + +DataType EverEqTjsonbJsonbLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTjsonbJsonbLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTjsonbJsonbLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTjsonbJsonbLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "EverEqTjsonbJsonbLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTjsonbJsonbLogicalFunction::getType() const { return NAME; } + +bool EverEqTjsonbJsonbLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTjsonbJsonbLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqTjsonbJsonbLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "json_str must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::VARSIZED), "target_json must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction EverEqTjsonbJsonbLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTjsonbJsonbLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverEqTjsonbJsonbLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return EverEqTjsonbJsonbLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTjsonbJsonbLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTjsonbJsonbLogicalFunction.cpp new file mode 100644 index 0000000000..fc161c6f65 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTjsonbJsonbLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTjsonbJsonbLogicalFunction::EverNeTjsonbJsonbLogicalFunction(LogicalFunction json_str, LogicalFunction ts, LogicalFunction target_json) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(json_str)); + parameters.push_back(std::move(ts)); + parameters.push_back(std::move(target_json)); +} + +DataType EverNeTjsonbJsonbLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTjsonbJsonbLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTjsonbJsonbLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTjsonbJsonbLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "EverNeTjsonbJsonbLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTjsonbJsonbLogicalFunction::getType() const { return NAME; } + +bool EverNeTjsonbJsonbLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTjsonbJsonbLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeTjsonbJsonbLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "json_str must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::VARSIZED), "target_json must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction EverNeTjsonbJsonbLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTjsonbJsonbLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "EverNeTjsonbJsonbLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return EverNeTjsonbJsonbLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTjsonbJsonbPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTjsonbJsonbPhysicalFunction.hpp new file mode 100644 index 0000000000..873bdd2b06 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTjsonbJsonbPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTjsonbJsonbPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTjsonbJsonbPhysicalFunction(PhysicalFunction json_str, PhysicalFunction ts, PhysicalFunction target_json); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTjsonbJsonbPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTjsonbJsonbPhysicalFunction.hpp new file mode 100644 index 0000000000..87c19495c7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTjsonbJsonbPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTjsonbJsonbPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTjsonbJsonbPhysicalFunction(PhysicalFunction json_str, PhysicalFunction ts, PhysicalFunction target_json); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTjsonbJsonbPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTjsonbJsonbPhysicalFunction.hpp new file mode 100644 index 0000000000..bc2a532a7e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTjsonbJsonbPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTjsonbJsonbPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTjsonbJsonbPhysicalFunction(PhysicalFunction json_str, PhysicalFunction ts, PhysicalFunction target_json); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTjsonbJsonbPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTjsonbJsonbPhysicalFunction.hpp new file mode 100644 index 0000000000..5dbb1e78b5 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTjsonbJsonbPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTjsonbJsonbPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTjsonbJsonbPhysicalFunction(PhysicalFunction json_str, PhysicalFunction ts, PhysicalFunction target_json); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTjsonbJsonbPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTjsonbJsonbPhysicalFunction.cpp new file mode 100644 index 0000000000..df011191c4 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTjsonbJsonbPhysicalFunction.cpp @@ -0,0 +1,85 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTjsonbJsonbPhysicalFunction::AlwaysEqTjsonbJsonbPhysicalFunction(PhysicalFunction json_str, PhysicalFunction ts, PhysicalFunction target_json) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(json_str)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(target_json)); +} + +VarVal AlwaysEqTjsonbJsonbPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto json_str = paramFns[0].execute(record, arena); + auto ts = paramFns[1].execute(record, arena).cast(); + auto target_json = paramFns[2].execute(record, arena); + const auto result = nautilus::invoke( + +[](const char* json_str, uint32_t json_len, uint64_t ts, const char* target_json, uint32_t target_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s1 = (char*)malloc(json_len + 1); + memcpy(s1, json_str, json_len); s1[json_len] = '\0'; + Jsonb* jb = jsonb_in(s1); free(s1); + if (!jb) return 0.0; + TInstant* inst = tjsonbinst_make(jb, (TimestampTz)ts); + free(jb); + if (!inst) return 0.0; + char* s2 = (char*)malloc(target_len + 1); + memcpy(s2, target_json, target_len); s2[target_len] = '\0'; + Jsonb* target = jsonb_in(s2); free(s2); + if (!target) { free(inst); return 0.0; } + bool r = always_eq_tjsonb_jsonb((Temporal*)inst, target) > 0; + free(inst); free(target); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + json_str, ts, target_json); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTjsonbJsonbPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysEqTjsonbJsonbPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTjsonbJsonbPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTjsonbJsonbPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTjsonbJsonbPhysicalFunction.cpp new file mode 100644 index 0000000000..c5cd9a5537 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTjsonbJsonbPhysicalFunction.cpp @@ -0,0 +1,85 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTjsonbJsonbPhysicalFunction::AlwaysNeTjsonbJsonbPhysicalFunction(PhysicalFunction json_str, PhysicalFunction ts, PhysicalFunction target_json) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(json_str)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(target_json)); +} + +VarVal AlwaysNeTjsonbJsonbPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto json_str = paramFns[0].execute(record, arena); + auto ts = paramFns[1].execute(record, arena).cast(); + auto target_json = paramFns[2].execute(record, arena); + const auto result = nautilus::invoke( + +[](const char* json_str, uint32_t json_len, uint64_t ts, const char* target_json, uint32_t target_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s1 = (char*)malloc(json_len + 1); + memcpy(s1, json_str, json_len); s1[json_len] = '\0'; + Jsonb* jb = jsonb_in(s1); free(s1); + if (!jb) return 0.0; + TInstant* inst = tjsonbinst_make(jb, (TimestampTz)ts); + free(jb); + if (!inst) return 0.0; + char* s2 = (char*)malloc(target_len + 1); + memcpy(s2, target_json, target_len); s2[target_len] = '\0'; + Jsonb* target = jsonb_in(s2); free(s2); + if (!target) { free(inst); return 0.0; } + bool r = always_ne_tjsonb_jsonb((Temporal*)inst, target) > 0; + free(inst); free(target); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + json_str, ts, target_json); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTjsonbJsonbPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "AlwaysNeTjsonbJsonbPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTjsonbJsonbPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 53f465f9d5..c7e8fbba38 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -432,6 +432,10 @@ add_plugin(QuadbinCellArea PhysicalFunction nes-physical-operators QuadbinCellAr add_plugin(QuadbinCellToQuadkey PhysicalFunction nes-physical-operators QuadbinCellToQuadkeyPhysicalFunction.cpp) add_plugin(QuadbinCellToParent PhysicalFunction nes-physical-operators QuadbinCellToParentPhysicalFunction.cpp) add_plugin(QuadbinTileToCell PhysicalFunction nes-physical-operators QuadbinTileToCellPhysicalFunction.cpp) +add_plugin(EverEqTjsonbJsonb PhysicalFunction nes-physical-operators EverEqTjsonbJsonbPhysicalFunction.cpp) +add_plugin(AlwaysEqTjsonbJsonb PhysicalFunction nes-physical-operators AlwaysEqTjsonbJsonbPhysicalFunction.cpp) +add_plugin(EverNeTjsonbJsonb PhysicalFunction nes-physical-operators EverNeTjsonbJsonbPhysicalFunction.cpp) +add_plugin(AlwaysNeTjsonbJsonb PhysicalFunction nes-physical-operators AlwaysNeTjsonbJsonbPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTjsonbJsonbPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTjsonbJsonbPhysicalFunction.cpp new file mode 100644 index 0000000000..92dea4c786 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTjsonbJsonbPhysicalFunction.cpp @@ -0,0 +1,85 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTjsonbJsonbPhysicalFunction::EverEqTjsonbJsonbPhysicalFunction(PhysicalFunction json_str, PhysicalFunction ts, PhysicalFunction target_json) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(json_str)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(target_json)); +} + +VarVal EverEqTjsonbJsonbPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto json_str = paramFns[0].execute(record, arena); + auto ts = paramFns[1].execute(record, arena).cast(); + auto target_json = paramFns[2].execute(record, arena); + const auto result = nautilus::invoke( + +[](const char* json_str, uint32_t json_len, uint64_t ts, const char* target_json, uint32_t target_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s1 = (char*)malloc(json_len + 1); + memcpy(s1, json_str, json_len); s1[json_len] = '\0'; + Jsonb* jb = jsonb_in(s1); free(s1); + if (!jb) return 0.0; + TInstant* inst = tjsonbinst_make(jb, (TimestampTz)ts); + free(jb); + if (!inst) return 0.0; + char* s2 = (char*)malloc(target_len + 1); + memcpy(s2, target_json, target_len); s2[target_len] = '\0'; + Jsonb* target = jsonb_in(s2); free(s2); + if (!target) { free(inst); return 0.0; } + bool r = ever_eq_tjsonb_jsonb((Temporal*)inst, target) > 0; + free(inst); free(target); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + json_str, ts, target_json); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTjsonbJsonbPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverEqTjsonbJsonbPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverEqTjsonbJsonbPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTjsonbJsonbPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTjsonbJsonbPhysicalFunction.cpp new file mode 100644 index 0000000000..05e67e0377 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTjsonbJsonbPhysicalFunction.cpp @@ -0,0 +1,85 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTjsonbJsonbPhysicalFunction::EverNeTjsonbJsonbPhysicalFunction(PhysicalFunction json_str, PhysicalFunction ts, PhysicalFunction target_json) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(json_str)); + paramFns.push_back(std::move(ts)); + paramFns.push_back(std::move(target_json)); +} + +VarVal EverNeTjsonbJsonbPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto json_str = paramFns[0].execute(record, arena); + auto ts = paramFns[1].execute(record, arena).cast(); + auto target_json = paramFns[2].execute(record, arena); + const auto result = nautilus::invoke( + +[](const char* json_str, uint32_t json_len, uint64_t ts, const char* target_json, uint32_t target_len) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s1 = (char*)malloc(json_len + 1); + memcpy(s1, json_str, json_len); s1[json_len] = '\0'; + Jsonb* jb = jsonb_in(s1); free(s1); + if (!jb) return 0.0; + TInstant* inst = tjsonbinst_make(jb, (TimestampTz)ts); + free(jb); + if (!inst) return 0.0; + char* s2 = (char*)malloc(target_len + 1); + memcpy(s2, target_json, target_len); s2[target_len] = '\0'; + Jsonb* target = jsonb_in(s2); free(s2); + if (!target) { free(inst); return 0.0; } + bool r = ever_ne_tjsonb_jsonb((Temporal*)inst, target) > 0; + free(inst); free(target); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + json_str, ts, target_json); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTjsonbJsonbPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "EverNeTjsonbJsonbPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return EverNeTjsonbJsonbPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 425bef310c..7ef694235c 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -903,6 +903,10 @@ QUADBIN_CELL_AREA: 'QUADBIN_CELL_AREA' | 'quadbin_cell_area'; QUADBIN_CELL_TO_QUADKEY: 'QUADBIN_CELL_TO_QUADKEY' | 'quadbin_cell_to_quadkey'; QUADBIN_CELL_TO_PARENT: 'QUADBIN_CELL_TO_PARENT' | 'quadbin_cell_to_parent'; QUADBIN_TILE_TO_CELL: 'QUADBIN_TILE_TO_CELL' | 'quadbin_tile_to_cell'; +EVER_EQ_TJSONB_JSONB: 'EVER_EQ_TJSONB_JSONB' | 'ever_eq_tjsonb_jsonb'; +ALWAYS_EQ_TJSONB_JSONB: 'ALWAYS_EQ_TJSONB_JSONB' | 'always_eq_tjsonb_jsonb'; +EVER_NE_TJSONB_JSONB: 'EVER_NE_TJSONB_JSONB' | 'ever_ne_tjsonb_jsonb'; +ALWAYS_NE_TJSONB_JSONB: 'ALWAYS_NE_TJSONB_JSONB' | 'always_ne_tjsonb_jsonb'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index e3a420f69d..c22b02a299 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -484,6 +484,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -10666,6 +10670,46 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(QuadbinTileToCellLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); } /* END CODEGEN PARSER GLUE: QUADBIN_TILE_TO_CELL */ + case AntlrSQLParser::EVER_EQ_TJSONB_JSONB: { + PRECONDITION(ctx->functionParam().size() == 3, + "EverEqTjsonbJsonb requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(EverEqTjsonbJsonbLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_TJSONB_JSONB */ + case AntlrSQLParser::ALWAYS_EQ_TJSONB_JSONB: { + PRECONDITION(ctx->functionParam().size() == 3, + "AlwaysEqTjsonbJsonb requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(AlwaysEqTjsonbJsonbLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TJSONB_JSONB */ + case AntlrSQLParser::EVER_NE_TJSONB_JSONB: { + PRECONDITION(ctx->functionParam().size() == 3, + "EverNeTjsonbJsonb requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(EverNeTjsonbJsonbLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_TJSONB_JSONB */ + case AntlrSQLParser::ALWAYS_NE_TJSONB_JSONB: { + PRECONDITION(ctx->functionParam().size() == 3, + "AlwaysNeTjsonbJsonb requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(AlwaysNeTjsonbJsonbLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TJSONB_JSONB */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 79975ddf40fe192c461f8c3296dabc88f43cdb2a Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 17:44:28 +0200 Subject: [PATCH 75/86] feat(meos): add TJSONB_TJSONB per-event comparison NES operators (W127) Wires four tjsonb-vs-tjsonb per-event scalar comparison operators using a 4-arg dual-instant pattern (json1:VARCHAR, ts1:UINT64, json2:VARCHAR, ts2:UINT64) -> FLOAT64. Each physical function deserializes two JSON strings via jsonb_in and wraps them as tjsonb instants via tjsonbinst_make. Operators: EVER_EQ/ALWAYS_EQ/EVER_NE/ALWAYS_NE_TJSONB_TJSONB (return 0.0/1.0). --- .../AlwaysEqTjsonbTjsonbLogicalFunction.hpp | 48 ++++++++ .../AlwaysNeTjsonbTjsonbLogicalFunction.hpp | 48 ++++++++ .../EverEqTjsonbTjsonbLogicalFunction.hpp | 48 ++++++++ .../EverNeTjsonbTjsonbLogicalFunction.hpp | 48 ++++++++ .../AlwaysEqTjsonbTjsonbLogicalFunction.cpp | 105 ++++++++++++++++++ .../AlwaysNeTjsonbTjsonbLogicalFunction.cpp | 105 ++++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../EverEqTjsonbTjsonbLogicalFunction.cpp | 105 ++++++++++++++++++ .../EverNeTjsonbTjsonbLogicalFunction.cpp | 105 ++++++++++++++++++ .../AlwaysEqTjsonbTjsonbPhysicalFunction.hpp | 32 ++++++ .../AlwaysNeTjsonbTjsonbPhysicalFunction.hpp | 32 ++++++ .../EverEqTjsonbTjsonbPhysicalFunction.hpp | 32 ++++++ .../EverNeTjsonbTjsonbPhysicalFunction.hpp | 32 ++++++ .../AlwaysEqTjsonbTjsonbPhysicalFunction.cpp | 91 +++++++++++++++ .../AlwaysNeTjsonbTjsonbPhysicalFunction.cpp | 91 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../EverEqTjsonbTjsonbPhysicalFunction.cpp | 91 +++++++++++++++ .../EverNeTjsonbTjsonbPhysicalFunction.cpp | 91 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 48 ++++++++ 20 files changed, 1165 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTjsonbTjsonbLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTjsonbTjsonbLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTjsonbTjsonbLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTjsonbTjsonbLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTjsonbTjsonbLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTjsonbTjsonbLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTjsonbTjsonbLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTjsonbTjsonbLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTjsonbTjsonbPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTjsonbTjsonbPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTjsonbTjsonbPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTjsonbTjsonbPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTjsonbTjsonbPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTjsonbTjsonbPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTjsonbTjsonbPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTjsonbTjsonbPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTjsonbTjsonbLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTjsonbTjsonbLogicalFunction.hpp new file mode 100644 index 0000000000..d73da9b4af --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTjsonbTjsonbLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tjsonb instants are always equal. + */ +class AlwaysEqTjsonbTjsonbLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTjsonbTjsonb"; + + AlwaysEqTjsonbTjsonbLogicalFunction(LogicalFunction json1, LogicalFunction ts1, LogicalFunction json2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTjsonbTjsonbLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTjsonbTjsonbLogicalFunction.hpp new file mode 100644 index 0000000000..eac1927655 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTjsonbTjsonbLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tjsonb instants are always not equal. + */ +class AlwaysNeTjsonbTjsonbLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTjsonbTjsonb"; + + AlwaysNeTjsonbTjsonbLogicalFunction(LogicalFunction json1, LogicalFunction ts1, LogicalFunction json2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTjsonbTjsonbLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTjsonbTjsonbLogicalFunction.hpp new file mode 100644 index 0000000000..70be614386 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTjsonbTjsonbLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tjsonb instants are ever equal. + */ +class EverEqTjsonbTjsonbLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTjsonbTjsonb"; + + EverEqTjsonbTjsonbLogicalFunction(LogicalFunction json1, LogicalFunction ts1, LogicalFunction json2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTjsonbTjsonbLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTjsonbTjsonbLogicalFunction.hpp new file mode 100644 index 0000000000..0b8af0041d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTjsonbTjsonbLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns 1.0 if the two tjsonb instants are ever not equal. + */ +class EverNeTjsonbTjsonbLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTjsonbTjsonb"; + + EverNeTjsonbTjsonbLogicalFunction(LogicalFunction json1, LogicalFunction ts1, LogicalFunction json2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTjsonbTjsonbLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTjsonbTjsonbLogicalFunction.cpp new file mode 100644 index 0000000000..5f2d9a1f6e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTjsonbTjsonbLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTjsonbTjsonbLogicalFunction::AlwaysEqTjsonbTjsonbLogicalFunction(LogicalFunction json1, LogicalFunction ts1, LogicalFunction json2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(json1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(json2)); + parameters.push_back(std::move(ts2)); +} + +DataType AlwaysEqTjsonbTjsonbLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTjsonbTjsonbLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTjsonbTjsonbLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTjsonbTjsonbLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "AlwaysEqTjsonbTjsonbLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTjsonbTjsonbLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTjsonbTjsonbLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTjsonbTjsonbLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqTjsonbTjsonbLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "json1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::VARSIZED), "json2 must be VARSIZED"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysEqTjsonbTjsonbLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTjsonbTjsonbLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "AlwaysEqTjsonbTjsonbLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return AlwaysEqTjsonbTjsonbLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTjsonbTjsonbLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTjsonbTjsonbLogicalFunction.cpp new file mode 100644 index 0000000000..337ad23193 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTjsonbTjsonbLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTjsonbTjsonbLogicalFunction::AlwaysNeTjsonbTjsonbLogicalFunction(LogicalFunction json1, LogicalFunction ts1, LogicalFunction json2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(json1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(json2)); + parameters.push_back(std::move(ts2)); +} + +DataType AlwaysNeTjsonbTjsonbLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTjsonbTjsonbLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTjsonbTjsonbLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTjsonbTjsonbLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "AlwaysNeTjsonbTjsonbLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTjsonbTjsonbLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTjsonbTjsonbLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTjsonbTjsonbLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeTjsonbTjsonbLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "json1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::VARSIZED), "json2 must be VARSIZED"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysNeTjsonbTjsonbLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTjsonbTjsonbLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "AlwaysNeTjsonbTjsonbLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return AlwaysNeTjsonbTjsonbLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 77b24cdd84..be94614fba 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -437,6 +437,10 @@ add_plugin(EverEqTjsonbJsonb LogicalFunction nes-logical-operators EverEqTjsonbJ add_plugin(AlwaysEqTjsonbJsonb LogicalFunction nes-logical-operators AlwaysEqTjsonbJsonbLogicalFunction.cpp) add_plugin(EverNeTjsonbJsonb LogicalFunction nes-logical-operators EverNeTjsonbJsonbLogicalFunction.cpp) add_plugin(AlwaysNeTjsonbJsonb LogicalFunction nes-logical-operators AlwaysNeTjsonbJsonbLogicalFunction.cpp) +add_plugin(EverEqTjsonbTjsonb LogicalFunction nes-logical-operators EverEqTjsonbTjsonbLogicalFunction.cpp) +add_plugin(AlwaysEqTjsonbTjsonb LogicalFunction nes-logical-operators AlwaysEqTjsonbTjsonbLogicalFunction.cpp) +add_plugin(EverNeTjsonbTjsonb LogicalFunction nes-logical-operators EverNeTjsonbTjsonbLogicalFunction.cpp) +add_plugin(AlwaysNeTjsonbTjsonb LogicalFunction nes-logical-operators AlwaysNeTjsonbTjsonbLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTjsonbTjsonbLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTjsonbTjsonbLogicalFunction.cpp new file mode 100644 index 0000000000..0e675053a7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTjsonbTjsonbLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTjsonbTjsonbLogicalFunction::EverEqTjsonbTjsonbLogicalFunction(LogicalFunction json1, LogicalFunction ts1, LogicalFunction json2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(json1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(json2)); + parameters.push_back(std::move(ts2)); +} + +DataType EverEqTjsonbTjsonbLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTjsonbTjsonbLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTjsonbTjsonbLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTjsonbTjsonbLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "EverEqTjsonbTjsonbLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTjsonbTjsonbLogicalFunction::getType() const { return NAME; } + +bool EverEqTjsonbTjsonbLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTjsonbTjsonbLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqTjsonbTjsonbLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "json1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::VARSIZED), "json2 must be VARSIZED"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverEqTjsonbTjsonbLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTjsonbTjsonbLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "EverEqTjsonbTjsonbLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return EverEqTjsonbTjsonbLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTjsonbTjsonbLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTjsonbTjsonbLogicalFunction.cpp new file mode 100644 index 0000000000..658fed2696 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTjsonbTjsonbLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTjsonbTjsonbLogicalFunction::EverNeTjsonbTjsonbLogicalFunction(LogicalFunction json1, LogicalFunction ts1, LogicalFunction json2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(4); + parameters.push_back(std::move(json1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(json2)); + parameters.push_back(std::move(ts2)); +} + +DataType EverNeTjsonbTjsonbLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTjsonbTjsonbLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTjsonbTjsonbLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTjsonbTjsonbLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "EverNeTjsonbTjsonbLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTjsonbTjsonbLogicalFunction::getType() const { return NAME; } + +bool EverNeTjsonbTjsonbLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTjsonbTjsonbLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeTjsonbTjsonbLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "json1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::VARSIZED), "json2 must be VARSIZED"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverNeTjsonbTjsonbLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTjsonbTjsonbLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "EverNeTjsonbTjsonbLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return EverNeTjsonbTjsonbLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTjsonbTjsonbPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTjsonbTjsonbPhysicalFunction.hpp new file mode 100644 index 0000000000..1e5ffc433c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTjsonbTjsonbPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTjsonbTjsonbPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTjsonbTjsonbPhysicalFunction(PhysicalFunction json1, PhysicalFunction ts1, PhysicalFunction json2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTjsonbTjsonbPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTjsonbTjsonbPhysicalFunction.hpp new file mode 100644 index 0000000000..fb24860d65 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTjsonbTjsonbPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTjsonbTjsonbPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTjsonbTjsonbPhysicalFunction(PhysicalFunction json1, PhysicalFunction ts1, PhysicalFunction json2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTjsonbTjsonbPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTjsonbTjsonbPhysicalFunction.hpp new file mode 100644 index 0000000000..8d77ff0b11 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTjsonbTjsonbPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTjsonbTjsonbPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTjsonbTjsonbPhysicalFunction(PhysicalFunction json1, PhysicalFunction ts1, PhysicalFunction json2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTjsonbTjsonbPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTjsonbTjsonbPhysicalFunction.hpp new file mode 100644 index 0000000000..4672a1af38 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTjsonbTjsonbPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTjsonbTjsonbPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTjsonbTjsonbPhysicalFunction(PhysicalFunction json1, PhysicalFunction ts1, PhysicalFunction json2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTjsonbTjsonbPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTjsonbTjsonbPhysicalFunction.cpp new file mode 100644 index 0000000000..ec8932d190 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTjsonbTjsonbPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTjsonbTjsonbPhysicalFunction::AlwaysEqTjsonbTjsonbPhysicalFunction(PhysicalFunction json1, PhysicalFunction ts1, PhysicalFunction json2, PhysicalFunction ts2) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(json1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(json2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AlwaysEqTjsonbTjsonbPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto json1 = paramFns[0].execute(record, arena); + auto ts1 = paramFns[1].execute(record, arena).cast(); + auto json2 = paramFns[2].execute(record, arena); + auto ts2 = paramFns[3].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* json1, uint32_t json1_len, uint64_t ts1, const char* json2, uint32_t json2_len, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s1 = (char*)malloc(json1_len + 1); + memcpy(s1, json1, json1_len); s1[json1_len] = '\0'; + Jsonb* jb1 = jsonb_in(s1); free(s1); + if (!jb1) return 0.0; + TInstant* inst1 = tjsonbinst_make(jb1, (TimestampTz)ts1); + free(jb1); + if (!inst1) return 0.0; + char* s2 = (char*)malloc(json2_len + 1); + memcpy(s2, json2, json2_len); s2[json2_len] = '\0'; + Jsonb* jb2 = jsonb_in(s2); free(s2); + if (!jb2) { free(inst1); return 0.0; } + TInstant* inst2 = tjsonbinst_make(jb2, (TimestampTz)ts2); + free(jb2); + if (!inst2) { free(inst1); return 0.0; } + int r = always_eq_tjsonb_tjsonb((Temporal*)inst1, (Temporal*)inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + json1, ts1, json2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTjsonbTjsonbPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "AlwaysEqTjsonbTjsonbPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTjsonbTjsonbPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTjsonbTjsonbPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTjsonbTjsonbPhysicalFunction.cpp new file mode 100644 index 0000000000..8bf4b65a00 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTjsonbTjsonbPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTjsonbTjsonbPhysicalFunction::AlwaysNeTjsonbTjsonbPhysicalFunction(PhysicalFunction json1, PhysicalFunction ts1, PhysicalFunction json2, PhysicalFunction ts2) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(json1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(json2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AlwaysNeTjsonbTjsonbPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto json1 = paramFns[0].execute(record, arena); + auto ts1 = paramFns[1].execute(record, arena).cast(); + auto json2 = paramFns[2].execute(record, arena); + auto ts2 = paramFns[3].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* json1, uint32_t json1_len, uint64_t ts1, const char* json2, uint32_t json2_len, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s1 = (char*)malloc(json1_len + 1); + memcpy(s1, json1, json1_len); s1[json1_len] = '\0'; + Jsonb* jb1 = jsonb_in(s1); free(s1); + if (!jb1) return 0.0; + TInstant* inst1 = tjsonbinst_make(jb1, (TimestampTz)ts1); + free(jb1); + if (!inst1) return 0.0; + char* s2 = (char*)malloc(json2_len + 1); + memcpy(s2, json2, json2_len); s2[json2_len] = '\0'; + Jsonb* jb2 = jsonb_in(s2); free(s2); + if (!jb2) { free(inst1); return 0.0; } + TInstant* inst2 = tjsonbinst_make(jb2, (TimestampTz)ts2); + free(jb2); + if (!inst2) { free(inst1); return 0.0; } + int r = always_ne_tjsonb_tjsonb((Temporal*)inst1, (Temporal*)inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + json1, ts1, json2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTjsonbTjsonbPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "AlwaysNeTjsonbTjsonbPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTjsonbTjsonbPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index c7e8fbba38..b9131ca967 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -436,6 +436,10 @@ add_plugin(EverEqTjsonbJsonb PhysicalFunction nes-physical-operators EverEqTjson add_plugin(AlwaysEqTjsonbJsonb PhysicalFunction nes-physical-operators AlwaysEqTjsonbJsonbPhysicalFunction.cpp) add_plugin(EverNeTjsonbJsonb PhysicalFunction nes-physical-operators EverNeTjsonbJsonbPhysicalFunction.cpp) add_plugin(AlwaysNeTjsonbJsonb PhysicalFunction nes-physical-operators AlwaysNeTjsonbJsonbPhysicalFunction.cpp) +add_plugin(EverEqTjsonbTjsonb PhysicalFunction nes-physical-operators EverEqTjsonbTjsonbPhysicalFunction.cpp) +add_plugin(AlwaysEqTjsonbTjsonb PhysicalFunction nes-physical-operators AlwaysEqTjsonbTjsonbPhysicalFunction.cpp) +add_plugin(EverNeTjsonbTjsonb PhysicalFunction nes-physical-operators EverNeTjsonbTjsonbPhysicalFunction.cpp) +add_plugin(AlwaysNeTjsonbTjsonb PhysicalFunction nes-physical-operators AlwaysNeTjsonbTjsonbPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTjsonbTjsonbPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTjsonbTjsonbPhysicalFunction.cpp new file mode 100644 index 0000000000..bbfb0752bb --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTjsonbTjsonbPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTjsonbTjsonbPhysicalFunction::EverEqTjsonbTjsonbPhysicalFunction(PhysicalFunction json1, PhysicalFunction ts1, PhysicalFunction json2, PhysicalFunction ts2) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(json1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(json2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EverEqTjsonbTjsonbPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto json1 = paramFns[0].execute(record, arena); + auto ts1 = paramFns[1].execute(record, arena).cast(); + auto json2 = paramFns[2].execute(record, arena); + auto ts2 = paramFns[3].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* json1, uint32_t json1_len, uint64_t ts1, const char* json2, uint32_t json2_len, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s1 = (char*)malloc(json1_len + 1); + memcpy(s1, json1, json1_len); s1[json1_len] = '\0'; + Jsonb* jb1 = jsonb_in(s1); free(s1); + if (!jb1) return 0.0; + TInstant* inst1 = tjsonbinst_make(jb1, (TimestampTz)ts1); + free(jb1); + if (!inst1) return 0.0; + char* s2 = (char*)malloc(json2_len + 1); + memcpy(s2, json2, json2_len); s2[json2_len] = '\0'; + Jsonb* jb2 = jsonb_in(s2); free(s2); + if (!jb2) { free(inst1); return 0.0; } + TInstant* inst2 = tjsonbinst_make(jb2, (TimestampTz)ts2); + free(jb2); + if (!inst2) { free(inst1); return 0.0; } + int r = ever_eq_tjsonb_tjsonb((Temporal*)inst1, (Temporal*)inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + json1, ts1, json2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTjsonbTjsonbPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "EverEqTjsonbTjsonbPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return EverEqTjsonbTjsonbPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTjsonbTjsonbPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTjsonbTjsonbPhysicalFunction.cpp new file mode 100644 index 0000000000..f060309a62 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTjsonbTjsonbPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTjsonbTjsonbPhysicalFunction::EverNeTjsonbTjsonbPhysicalFunction(PhysicalFunction json1, PhysicalFunction ts1, PhysicalFunction json2, PhysicalFunction ts2) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(json1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(json2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EverNeTjsonbTjsonbPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto json1 = paramFns[0].execute(record, arena); + auto ts1 = paramFns[1].execute(record, arena).cast(); + auto json2 = paramFns[2].execute(record, arena); + auto ts2 = paramFns[3].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* json1, uint32_t json1_len, uint64_t ts1, const char* json2, uint32_t json2_len, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + char* s1 = (char*)malloc(json1_len + 1); + memcpy(s1, json1, json1_len); s1[json1_len] = '\0'; + Jsonb* jb1 = jsonb_in(s1); free(s1); + if (!jb1) return 0.0; + TInstant* inst1 = tjsonbinst_make(jb1, (TimestampTz)ts1); + free(jb1); + if (!inst1) return 0.0; + char* s2 = (char*)malloc(json2_len + 1); + memcpy(s2, json2, json2_len); s2[json2_len] = '\0'; + Jsonb* jb2 = jsonb_in(s2); free(s2); + if (!jb2) { free(inst1); return 0.0; } + TInstant* inst2 = tjsonbinst_make(jb2, (TimestampTz)ts2); + free(jb2); + if (!inst2) { free(inst1); return 0.0; } + int r = ever_ne_tjsonb_tjsonb((Temporal*)inst1, (Temporal*)inst2); + free(inst1); free(inst2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + json1, ts1, json2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTjsonbTjsonbPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "EverNeTjsonbTjsonbPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return EverNeTjsonbTjsonbPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 7ef694235c..00a5e0ed76 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -907,6 +907,10 @@ EVER_EQ_TJSONB_JSONB: 'EVER_EQ_TJSONB_JSONB' | 'ever_eq_tjsonb_jsonb'; ALWAYS_EQ_TJSONB_JSONB: 'ALWAYS_EQ_TJSONB_JSONB' | 'always_eq_tjsonb_jsonb'; EVER_NE_TJSONB_JSONB: 'EVER_NE_TJSONB_JSONB' | 'ever_ne_tjsonb_jsonb'; ALWAYS_NE_TJSONB_JSONB: 'ALWAYS_NE_TJSONB_JSONB' | 'always_ne_tjsonb_jsonb'; +EVER_EQ_TJSONB_TJSONB: 'EVER_EQ_TJSONB_TJSONB' | 'ever_eq_tjsonb_tjsonb'; +ALWAYS_EQ_TJSONB_TJSONB: 'ALWAYS_EQ_TJSONB_TJSONB' | 'always_eq_tjsonb_tjsonb'; +EVER_NE_TJSONB_TJSONB: 'EVER_NE_TJSONB_TJSONB' | 'ever_ne_tjsonb_tjsonb'; +ALWAYS_NE_TJSONB_TJSONB: 'ALWAYS_NE_TJSONB_TJSONB' | 'always_ne_tjsonb_tjsonb'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index c22b02a299..dd8d05c0f6 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -488,6 +488,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -10710,6 +10714,50 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(AlwaysNeTjsonbJsonbLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); } /* END CODEGEN PARSER GLUE: ALWAYS_NE_TJSONB_JSONB */ + case AntlrSQLParser::EVER_EQ_TJSONB_TJSONB: { + PRECONDITION(ctx->functionParam().size() == 4, + "EverEqTjsonbTjsonb requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(EverEqTjsonbTjsonbLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_TJSONB_TJSONB */ + case AntlrSQLParser::ALWAYS_EQ_TJSONB_TJSONB: { + PRECONDITION(ctx->functionParam().size() == 4, + "AlwaysEqTjsonbTjsonb requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(AlwaysEqTjsonbTjsonbLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TJSONB_TJSONB */ + case AntlrSQLParser::EVER_NE_TJSONB_TJSONB: { + PRECONDITION(ctx->functionParam().size() == 4, + "EverNeTjsonbTjsonb requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(EverNeTjsonbTjsonbLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_TJSONB_TJSONB */ + case AntlrSQLParser::ALWAYS_NE_TJSONB_TJSONB: { + PRECONDITION(ctx->functionParam().size() == 4, + "AlwaysNeTjsonbTjsonb requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(AlwaysNeTjsonbTjsonbLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TJSONB_TJSONB */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 86722424c148d4a820dbfad7ed6adb026ca3da2e Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 20:14:36 +0200 Subject: [PATCH 76/86] feat(meos): add unary geometry transform NES operators returning WKT (W128) Wires GEOM_BOUNDARY, GEOM_CENTROID, GEOM_CONVEX_HULL, GEO_REVERSE, GEO_POINTS, and GEOM_UNARY_UNION as 1-arg (wkt:VARCHAR) -> VARCHAR operators. Each physical function parses the WKT input via geom_in, calls the corresponding MEOS GSERIALIZED-returning function, then serializes the result with geo_as_text into an arena-allocated buffer. --- .../Meos/GeoPointsLogicalFunction.hpp | 48 ++++++++++ .../Meos/GeoReverseLogicalFunction.hpp | 48 ++++++++++ .../Meos/GeomBoundaryLogicalFunction.hpp | 48 ++++++++++ .../Meos/GeomCentroidLogicalFunction.hpp | 48 ++++++++++ .../Meos/GeomConvexHullLogicalFunction.hpp | 48 ++++++++++ .../Meos/GeomUnaryUnionLogicalFunction.hpp | 48 ++++++++++ .../src/Functions/Meos/CMakeLists.txt | 6 ++ .../Meos/GeoPointsLogicalFunction.cpp | 96 +++++++++++++++++++ .../Meos/GeoReverseLogicalFunction.cpp | 96 +++++++++++++++++++ .../Meos/GeomBoundaryLogicalFunction.cpp | 96 +++++++++++++++++++ .../Meos/GeomCentroidLogicalFunction.cpp | 96 +++++++++++++++++++ .../Meos/GeomConvexHullLogicalFunction.cpp | 96 +++++++++++++++++++ .../Meos/GeomUnaryUnionLogicalFunction.cpp | 96 +++++++++++++++++++ .../Meos/GeoPointsPhysicalFunction.hpp | 32 +++++++ .../Meos/GeoReversePhysicalFunction.hpp | 32 +++++++ .../Meos/GeomBoundaryPhysicalFunction.hpp | 32 +++++++ .../Meos/GeomCentroidPhysicalFunction.hpp | 32 +++++++ .../Meos/GeomConvexHullPhysicalFunction.hpp | 32 +++++++ .../Meos/GeomUnaryUnionPhysicalFunction.hpp | 32 +++++++ .../src/Functions/Meos/CMakeLists.txt | 6 ++ .../Meos/GeoPointsPhysicalFunction.cpp | 84 ++++++++++++++++ .../Meos/GeoReversePhysicalFunction.cpp | 84 ++++++++++++++++ .../Meos/GeomBoundaryPhysicalFunction.cpp | 84 ++++++++++++++++ .../Meos/GeomCentroidPhysicalFunction.cpp | 84 ++++++++++++++++ .../Meos/GeomConvexHullPhysicalFunction.cpp | 84 ++++++++++++++++ .../Meos/GeomUnaryUnionPhysicalFunction.cpp | 84 ++++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 8 +- .../src/AntlrSQLQueryPlanCreator.cpp | 54 +++++++++++ 28 files changed, 1633 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeoPointsLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeoReverseLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomBoundaryLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomCentroidLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomConvexHullLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomUnaryUnionLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoPointsLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoReverseLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomBoundaryLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomCentroidLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomConvexHullLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomUnaryUnionLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoPointsPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoReversePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomBoundaryPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomCentroidPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomConvexHullPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomUnaryUnionPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoPointsPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoReversePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomBoundaryPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomCentroidPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomConvexHullPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomUnaryUnionPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeoPointsLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoPointsLogicalFunction.hpp new file mode 100644 index 0000000000..445a9384d8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoPointsLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns a multi-point geometry of all vertices as WKT. + */ +class GeoPointsLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoPoints"; + + GeoPointsLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeoReverseLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoReverseLogicalFunction.hpp new file mode 100644 index 0000000000..637e401c3d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoReverseLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the geometry with vertex order reversed as WKT. + */ +class GeoReverseLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoReverse"; + + GeoReverseLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomBoundaryLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomBoundaryLogicalFunction.hpp new file mode 100644 index 0000000000..bc7a730b1a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomBoundaryLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the boundary of a geometry as WKT. + */ +class GeomBoundaryLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomBoundary"; + + GeomBoundaryLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomCentroidLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomCentroidLogicalFunction.hpp new file mode 100644 index 0000000000..d79f0a2beb --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomCentroidLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the centroid of a geometry as WKT. + */ +class GeomCentroidLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomCentroid"; + + GeomCentroidLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomConvexHullLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomConvexHullLogicalFunction.hpp new file mode 100644 index 0000000000..cf854b2267 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomConvexHullLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the convex hull of a geometry as WKT. + */ +class GeomConvexHullLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomConvexHull"; + + GeomConvexHullLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomUnaryUnionLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomUnaryUnionLogicalFunction.hpp new file mode 100644 index 0000000000..3b8dfed730 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomUnaryUnionLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the topological union of a geometry's components as WKT. + */ +class GeomUnaryUnionLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomUnaryUnion"; + + GeomUnaryUnionLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index be94614fba..4640cb63ed 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -441,6 +441,12 @@ add_plugin(EverEqTjsonbTjsonb LogicalFunction nes-logical-operators EverEqTjsonb add_plugin(AlwaysEqTjsonbTjsonb LogicalFunction nes-logical-operators AlwaysEqTjsonbTjsonbLogicalFunction.cpp) add_plugin(EverNeTjsonbTjsonb LogicalFunction nes-logical-operators EverNeTjsonbTjsonbLogicalFunction.cpp) add_plugin(AlwaysNeTjsonbTjsonb LogicalFunction nes-logical-operators AlwaysNeTjsonbTjsonbLogicalFunction.cpp) +add_plugin(GeomBoundary LogicalFunction nes-logical-operators GeomBoundaryLogicalFunction.cpp) +add_plugin(GeomCentroid LogicalFunction nes-logical-operators GeomCentroidLogicalFunction.cpp) +add_plugin(GeomConvexHull LogicalFunction nes-logical-operators GeomConvexHullLogicalFunction.cpp) +add_plugin(GeoReverse LogicalFunction nes-logical-operators GeoReverseLogicalFunction.cpp) +add_plugin(GeoPoints LogicalFunction nes-logical-operators GeoPointsLogicalFunction.cpp) +add_plugin(GeomUnaryUnion LogicalFunction nes-logical-operators GeomUnaryUnionLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeoPointsLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoPointsLogicalFunction.cpp new file mode 100644 index 0000000000..59507b39c0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoPointsLogicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoPointsLogicalFunction::GeoPointsLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeoPointsLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoPointsLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoPointsLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoPointsLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeoPointsLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoPointsLogicalFunction::getType() const { return NAME; } + +bool GeoPointsLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoPointsLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoPointsLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeoPointsLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoPointsLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeoPointsLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return GeoPointsLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeoReverseLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoReverseLogicalFunction.cpp new file mode 100644 index 0000000000..e70629d6e0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoReverseLogicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoReverseLogicalFunction::GeoReverseLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeoReverseLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoReverseLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoReverseLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoReverseLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeoReverseLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoReverseLogicalFunction::getType() const { return NAME; } + +bool GeoReverseLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoReverseLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoReverseLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeoReverseLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoReverseLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeoReverseLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return GeoReverseLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomBoundaryLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomBoundaryLogicalFunction.cpp new file mode 100644 index 0000000000..2f901cfdfb --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomBoundaryLogicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomBoundaryLogicalFunction::GeomBoundaryLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeomBoundaryLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomBoundaryLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomBoundaryLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomBoundaryLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeomBoundaryLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomBoundaryLogicalFunction::getType() const { return NAME; } + +bool GeomBoundaryLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomBoundaryLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomBoundaryLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomBoundaryLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomBoundaryLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeomBoundaryLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return GeomBoundaryLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomCentroidLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomCentroidLogicalFunction.cpp new file mode 100644 index 0000000000..1627911bc7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomCentroidLogicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomCentroidLogicalFunction::GeomCentroidLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeomCentroidLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomCentroidLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomCentroidLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomCentroidLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeomCentroidLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomCentroidLogicalFunction::getType() const { return NAME; } + +bool GeomCentroidLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomCentroidLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomCentroidLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomCentroidLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomCentroidLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeomCentroidLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return GeomCentroidLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomConvexHullLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomConvexHullLogicalFunction.cpp new file mode 100644 index 0000000000..6a011ddf3a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomConvexHullLogicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomConvexHullLogicalFunction::GeomConvexHullLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeomConvexHullLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomConvexHullLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomConvexHullLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomConvexHullLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeomConvexHullLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomConvexHullLogicalFunction::getType() const { return NAME; } + +bool GeomConvexHullLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomConvexHullLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomConvexHullLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomConvexHullLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomConvexHullLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeomConvexHullLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return GeomConvexHullLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomUnaryUnionLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomUnaryUnionLogicalFunction.cpp new file mode 100644 index 0000000000..9155f6d913 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomUnaryUnionLogicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomUnaryUnionLogicalFunction::GeomUnaryUnionLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeomUnaryUnionLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomUnaryUnionLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomUnaryUnionLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomUnaryUnionLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeomUnaryUnionLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomUnaryUnionLogicalFunction::getType() const { return NAME; } + +bool GeomUnaryUnionLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomUnaryUnionLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomUnaryUnionLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomUnaryUnionLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomUnaryUnionLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeomUnaryUnionLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return GeomUnaryUnionLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoPointsPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoPointsPhysicalFunction.hpp new file mode 100644 index 0000000000..84a1a22979 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoPointsPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoPointsPhysicalFunction : public PhysicalFunctionConcept { +public: + GeoPointsPhysicalFunction(PhysicalFunction wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoReversePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoReversePhysicalFunction.hpp new file mode 100644 index 0000000000..47707c49b1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoReversePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoReversePhysicalFunction : public PhysicalFunctionConcept { +public: + GeoReversePhysicalFunction(PhysicalFunction wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomBoundaryPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomBoundaryPhysicalFunction.hpp new file mode 100644 index 0000000000..af559402d7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomBoundaryPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomBoundaryPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomBoundaryPhysicalFunction(PhysicalFunction wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomCentroidPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomCentroidPhysicalFunction.hpp new file mode 100644 index 0000000000..4701a611bb --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomCentroidPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomCentroidPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomCentroidPhysicalFunction(PhysicalFunction wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomConvexHullPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomConvexHullPhysicalFunction.hpp new file mode 100644 index 0000000000..70f3cbe643 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomConvexHullPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomConvexHullPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomConvexHullPhysicalFunction(PhysicalFunction wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomUnaryUnionPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomUnaryUnionPhysicalFunction.hpp new file mode 100644 index 0000000000..e09db70ba5 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomUnaryUnionPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomUnaryUnionPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomUnaryUnionPhysicalFunction(PhysicalFunction wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index b9131ca967..2379ee5bc1 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -440,6 +440,12 @@ add_plugin(EverEqTjsonbTjsonb PhysicalFunction nes-physical-operators EverEqTjso add_plugin(AlwaysEqTjsonbTjsonb PhysicalFunction nes-physical-operators AlwaysEqTjsonbTjsonbPhysicalFunction.cpp) add_plugin(EverNeTjsonbTjsonb PhysicalFunction nes-physical-operators EverNeTjsonbTjsonbPhysicalFunction.cpp) add_plugin(AlwaysNeTjsonbTjsonb PhysicalFunction nes-physical-operators AlwaysNeTjsonbTjsonbPhysicalFunction.cpp) +add_plugin(GeomBoundary PhysicalFunction nes-physical-operators GeomBoundaryPhysicalFunction.cpp) +add_plugin(GeomCentroid PhysicalFunction nes-physical-operators GeomCentroidPhysicalFunction.cpp) +add_plugin(GeomConvexHull PhysicalFunction nes-physical-operators GeomConvexHullPhysicalFunction.cpp) +add_plugin(GeoReverse PhysicalFunction nes-physical-operators GeoReversePhysicalFunction.cpp) +add_plugin(GeoPoints PhysicalFunction nes-physical-operators GeoPointsPhysicalFunction.cpp) +add_plugin(GeomUnaryUnion PhysicalFunction nes-physical-operators GeomUnaryUnionPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/GeoPointsPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoPointsPhysicalFunction.cpp new file mode 100644 index 0000000000..663752a656 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoPointsPhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoPointsPhysicalFunction::GeoPointsPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeoPointsPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* wkt, uint32_t wsz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(wkt, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geo_points(gs); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, outBuf.getContent(), nautilus::val(8192)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoPointsPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeoPointsPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return GeoPointsPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeoReversePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoReversePhysicalFunction.cpp new file mode 100644 index 0000000000..43b6d87faf --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoReversePhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoReversePhysicalFunction::GeoReversePhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeoReversePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* wkt, uint32_t wsz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(wkt, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geo_reverse(gs); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, outBuf.getContent(), nautilus::val(8192)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoReversePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeoReversePhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return GeoReversePhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomBoundaryPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomBoundaryPhysicalFunction.cpp new file mode 100644 index 0000000000..c2dc54d45d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomBoundaryPhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomBoundaryPhysicalFunction::GeomBoundaryPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeomBoundaryPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* wkt, uint32_t wsz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(wkt, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geom_boundary(gs); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, outBuf.getContent(), nautilus::val(8192)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomBoundaryPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeomBoundaryPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return GeomBoundaryPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomCentroidPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomCentroidPhysicalFunction.cpp new file mode 100644 index 0000000000..380553bc1c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomCentroidPhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomCentroidPhysicalFunction::GeomCentroidPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeomCentroidPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* wkt, uint32_t wsz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(wkt, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geom_centroid(gs); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, outBuf.getContent(), nautilus::val(8192)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomCentroidPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeomCentroidPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return GeomCentroidPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomConvexHullPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomConvexHullPhysicalFunction.cpp new file mode 100644 index 0000000000..139552c7f9 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomConvexHullPhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomConvexHullPhysicalFunction::GeomConvexHullPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeomConvexHullPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* wkt, uint32_t wsz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(wkt, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geom_convex_hull(gs); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, outBuf.getContent(), nautilus::val(8192)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomConvexHullPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeomConvexHullPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return GeomConvexHullPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomUnaryUnionPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomUnaryUnionPhysicalFunction.cpp new file mode 100644 index 0000000000..bfc68105ce --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomUnaryUnionPhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomUnaryUnionPhysicalFunction::GeomUnaryUnionPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeomUnaryUnionPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* wkt, uint32_t wsz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(wkt, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geom_unary_union(gs, 0.0); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, outBuf.getContent(), nautilus::val(8192)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomUnaryUnionPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeomUnaryUnionPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return GeomUnaryUnionPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 00a5e0ed76..2015773c7d 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -911,6 +911,12 @@ EVER_EQ_TJSONB_TJSONB: 'EVER_EQ_TJSONB_TJSONB' | 'ever_eq_tjsonb_tjsonb'; ALWAYS_EQ_TJSONB_TJSONB: 'ALWAYS_EQ_TJSONB_TJSONB' | 'always_eq_tjsonb_tjsonb'; EVER_NE_TJSONB_TJSONB: 'EVER_NE_TJSONB_TJSONB' | 'ever_ne_tjsonb_tjsonb'; ALWAYS_NE_TJSONB_TJSONB: 'ALWAYS_NE_TJSONB_TJSONB' | 'always_ne_tjsonb_tjsonb'; +GEOM_BOUNDARY: 'GEOM_BOUNDARY' | 'geom_boundary'; +GEOM_CENTROID: 'GEOM_CENTROID' | 'geom_centroid'; +GEOM_CONVEX_HULL: 'GEOM_CONVEX_HULL' | 'geom_convex_hull'; +GEO_REVERSE: 'GEO_REVERSE' | 'geo_reverse'; +GEO_POINTS: 'GEO_POINTS' | 'geo_points'; +GEOM_UNARY_UNION: 'GEOM_UNARY_UNION' | 'geom_unary_union'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index dd8d05c0f6..26a8e82191 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -492,6 +492,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include @@ -10758,6 +10764,54 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(AlwaysNeTjsonbTjsonbLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); } /* END CODEGEN PARSER GLUE: ALWAYS_NE_TJSONB_TJSONB */ + case AntlrSQLParser::GEOM_BOUNDARY: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeomBoundary requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeomBoundaryLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOM_BOUNDARY */ + case AntlrSQLParser::GEOM_CENTROID: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeomCentroid requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeomCentroidLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOM_CENTROID */ + case AntlrSQLParser::GEOM_CONVEX_HULL: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeomConvexHull requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeomConvexHullLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOM_CONVEX_HULL */ + case AntlrSQLParser::GEO_REVERSE: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeoReverse requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeoReverseLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEO_REVERSE */ + case AntlrSQLParser::GEO_POINTS: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeoPoints requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeoPointsLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEO_POINTS */ + case AntlrSQLParser::GEOM_UNARY_UNION: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeomUnaryUnion requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeomUnaryUnionLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOM_UNARY_UNION */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From e288070779d6dbe6128a91c0c26413a321a36346 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 20:17:34 +0200 Subject: [PATCH 77/86] feat(meos): add binary geometry set operation NES operators returning WKT (W129) Wires GEOM_DIFFERENCE2D, GEOM_INTERSECTION2D, GEOM_SHORTESTLINE2D, and GEOM_SHORTESTLINE3D as 2-arg (wkt1:VARCHAR, wkt2:VARCHAR) -> VARCHAR operators. Each physical function parses both WKT inputs via geom_in, calls the corresponding MEOS GSERIALIZED-returning function, then serializes the result with geo_as_text into an arena-allocated buffer. --- .../Meos/GeomDifference2dLogicalFunction.hpp | 48 +++++++++ .../GeomIntersection2dLogicalFunction.hpp | 48 +++++++++ .../GeomShortestline2dLogicalFunction.hpp | 48 +++++++++ .../GeomShortestline3dLogicalFunction.hpp | 48 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/GeomDifference2dLogicalFunction.cpp | 99 +++++++++++++++++++ .../GeomIntersection2dLogicalFunction.cpp | 99 +++++++++++++++++++ .../GeomShortestline2dLogicalFunction.cpp | 99 +++++++++++++++++++ .../GeomShortestline3dLogicalFunction.cpp | 99 +++++++++++++++++++ .../Meos/GeomDifference2dPhysicalFunction.hpp | 32 ++++++ .../GeomIntersection2dPhysicalFunction.hpp | 32 ++++++ .../GeomShortestline2dPhysicalFunction.hpp | 32 ++++++ .../GeomShortestline3dPhysicalFunction.hpp | 32 ++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/GeomDifference2dPhysicalFunction.cpp | 90 +++++++++++++++++ .../GeomIntersection2dPhysicalFunction.cpp | 90 +++++++++++++++++ .../GeomShortestline2dPhysicalFunction.cpp | 90 +++++++++++++++++ .../GeomShortestline3dPhysicalFunction.cpp | 90 +++++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 40 ++++++++ 20 files changed, 1129 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeomDifference2dLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomIntersection2dLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomShortestline2dLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomShortestline3dLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomDifference2dLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomIntersection2dLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomShortestline2dLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomShortestline3dLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomDifference2dPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomIntersection2dPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomShortestline2dPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomShortestline3dPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomDifference2dPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomIntersection2dPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomShortestline2dPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomShortestline3dPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeomDifference2dLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomDifference2dLogicalFunction.hpp new file mode 100644 index 0000000000..49f8582d56 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomDifference2dLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the geometric difference of two geometries as WKT. + */ +class GeomDifference2dLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomDifference2d"; + + GeomDifference2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomIntersection2dLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomIntersection2dLogicalFunction.hpp new file mode 100644 index 0000000000..90e577a923 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomIntersection2dLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the geometric intersection of two geometries as WKT. + */ +class GeomIntersection2dLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomIntersection2d"; + + GeomIntersection2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomShortestline2dLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomShortestline2dLogicalFunction.hpp new file mode 100644 index 0000000000..8c8e93a69b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomShortestline2dLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the shortest 2D line between two geometries as WKT. + */ +class GeomShortestline2dLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomShortestline2d"; + + GeomShortestline2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomShortestline3dLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomShortestline3dLogicalFunction.hpp new file mode 100644 index 0000000000..8501c2783f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomShortestline3dLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the shortest 3D line between two geometries as WKT. + */ +class GeomShortestline3dLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomShortestline3d"; + + GeomShortestline3dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 4640cb63ed..fa52006a97 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -447,6 +447,10 @@ add_plugin(GeomConvexHull LogicalFunction nes-logical-operators GeomConvexHullLo add_plugin(GeoReverse LogicalFunction nes-logical-operators GeoReverseLogicalFunction.cpp) add_plugin(GeoPoints LogicalFunction nes-logical-operators GeoPointsLogicalFunction.cpp) add_plugin(GeomUnaryUnion LogicalFunction nes-logical-operators GeomUnaryUnionLogicalFunction.cpp) +add_plugin(GeomDifference2d LogicalFunction nes-logical-operators GeomDifference2dLogicalFunction.cpp) +add_plugin(GeomIntersection2d LogicalFunction nes-logical-operators GeomIntersection2dLogicalFunction.cpp) +add_plugin(GeomShortestline2d LogicalFunction nes-logical-operators GeomShortestline2dLogicalFunction.cpp) +add_plugin(GeomShortestline3d LogicalFunction nes-logical-operators GeomShortestline3dLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeomDifference2dLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomDifference2dLogicalFunction.cpp new file mode 100644 index 0000000000..8637060821 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomDifference2dLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomDifference2dLogicalFunction::GeomDifference2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomDifference2dLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomDifference2dLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomDifference2dLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomDifference2dLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeomDifference2dLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomDifference2dLogicalFunction::getType() const { return NAME; } + +bool GeomDifference2dLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomDifference2dLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomDifference2dLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomDifference2dLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomDifference2dLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomDifference2dLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomDifference2dLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomIntersection2dLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomIntersection2dLogicalFunction.cpp new file mode 100644 index 0000000000..905e630f09 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomIntersection2dLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomIntersection2dLogicalFunction::GeomIntersection2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomIntersection2dLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomIntersection2dLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomIntersection2dLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomIntersection2dLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeomIntersection2dLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomIntersection2dLogicalFunction::getType() const { return NAME; } + +bool GeomIntersection2dLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomIntersection2dLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomIntersection2dLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomIntersection2dLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomIntersection2dLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomIntersection2dLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomIntersection2dLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomShortestline2dLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomShortestline2dLogicalFunction.cpp new file mode 100644 index 0000000000..4bbbba645f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomShortestline2dLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomShortestline2dLogicalFunction::GeomShortestline2dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomShortestline2dLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomShortestline2dLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomShortestline2dLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomShortestline2dLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeomShortestline2dLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomShortestline2dLogicalFunction::getType() const { return NAME; } + +bool GeomShortestline2dLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomShortestline2dLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomShortestline2dLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomShortestline2dLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomShortestline2dLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomShortestline2dLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomShortestline2dLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomShortestline3dLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomShortestline3dLogicalFunction.cpp new file mode 100644 index 0000000000..83d24813e8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomShortestline3dLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomShortestline3dLogicalFunction::GeomShortestline3dLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomShortestline3dLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomShortestline3dLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomShortestline3dLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomShortestline3dLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeomShortestline3dLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomShortestline3dLogicalFunction::getType() const { return NAME; } + +bool GeomShortestline3dLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomShortestline3dLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomShortestline3dLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomShortestline3dLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomShortestline3dLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomShortestline3dLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomShortestline3dLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomDifference2dPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomDifference2dPhysicalFunction.hpp new file mode 100644 index 0000000000..4e5ebac981 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomDifference2dPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomDifference2dPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomDifference2dPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomIntersection2dPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomIntersection2dPhysicalFunction.hpp new file mode 100644 index 0000000000..80cee17fa6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomIntersection2dPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomIntersection2dPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomIntersection2dPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomShortestline2dPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomShortestline2dPhysicalFunction.hpp new file mode 100644 index 0000000000..a7bf75d20f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomShortestline2dPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomShortestline2dPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomShortestline2dPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomShortestline3dPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomShortestline3dPhysicalFunction.hpp new file mode 100644 index 0000000000..ffc731f5d2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomShortestline3dPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomShortestline3dPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomShortestline3dPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 2379ee5bc1..c6aede88f6 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -446,6 +446,10 @@ add_plugin(GeomConvexHull PhysicalFunction nes-physical-operators GeomConvexHull add_plugin(GeoReverse PhysicalFunction nes-physical-operators GeoReversePhysicalFunction.cpp) add_plugin(GeoPoints PhysicalFunction nes-physical-operators GeoPointsPhysicalFunction.cpp) add_plugin(GeomUnaryUnion PhysicalFunction nes-physical-operators GeomUnaryUnionPhysicalFunction.cpp) +add_plugin(GeomDifference2d PhysicalFunction nes-physical-operators GeomDifference2dPhysicalFunction.cpp) +add_plugin(GeomIntersection2d PhysicalFunction nes-physical-operators GeomIntersection2dPhysicalFunction.cpp) +add_plugin(GeomShortestline2d PhysicalFunction nes-physical-operators GeomShortestline2dPhysicalFunction.cpp) +add_plugin(GeomShortestline3d PhysicalFunction nes-physical-operators GeomShortestline3dPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/GeomDifference2dPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomDifference2dPhysicalFunction.cpp new file mode 100644 index 0000000000..dbc64686f2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomDifference2dPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomDifference2dPhysicalFunction::GeomDifference2dPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); +} + +VarVal GeomDifference2dPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0u; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0u; } + GSERIALIZED* result = geom_difference2d(gs1, gs2); + free(gs1); free(gs2); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt1, wkt2, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomDifference2dPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomDifference2dPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomDifference2dPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomIntersection2dPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomIntersection2dPhysicalFunction.cpp new file mode 100644 index 0000000000..574fad5631 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomIntersection2dPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomIntersection2dPhysicalFunction::GeomIntersection2dPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); +} + +VarVal GeomIntersection2dPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0u; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0u; } + GSERIALIZED* result = geom_intersection2d(gs1, gs2); + free(gs1); free(gs2); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt1, wkt2, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomIntersection2dPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomIntersection2dPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomIntersection2dPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomShortestline2dPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomShortestline2dPhysicalFunction.cpp new file mode 100644 index 0000000000..7a1ad18e0c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomShortestline2dPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomShortestline2dPhysicalFunction::GeomShortestline2dPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); +} + +VarVal GeomShortestline2dPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0u; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0u; } + GSERIALIZED* result = geom_shortestline2d(gs1, gs2); + free(gs1); free(gs2); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt1, wkt2, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomShortestline2dPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomShortestline2dPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomShortestline2dPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomShortestline3dPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomShortestline3dPhysicalFunction.cpp new file mode 100644 index 0000000000..d95bb20070 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomShortestline3dPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomShortestline3dPhysicalFunction::GeomShortestline3dPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); +} + +VarVal GeomShortestline3dPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0u; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0u; } + GSERIALIZED* result = geom_shortestline3d(gs1, gs2); + free(gs1); free(gs2); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt1, wkt2, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomShortestline3dPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomShortestline3dPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomShortestline3dPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 2015773c7d..f6accd04b1 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -917,6 +917,10 @@ GEOM_CONVEX_HULL: 'GEOM_CONVEX_HULL' | 'geom_convex_hull'; GEO_REVERSE: 'GEO_REVERSE' | 'geo_reverse'; GEO_POINTS: 'GEO_POINTS' | 'geo_points'; GEOM_UNARY_UNION: 'GEOM_UNARY_UNION' | 'geom_unary_union'; +GEOM_DIFFERENCE2D: 'GEOM_DIFFERENCE2D' | 'geom_difference2d'; +GEOM_INTERSECTION2D: 'GEOM_INTERSECTION2D' | 'geom_intersection2d'; +GEOM_SHORTESTLINE2D: 'GEOM_SHORTESTLINE2D' | 'geom_shortestline2d'; +GEOM_SHORTESTLINE3D: 'GEOM_SHORTESTLINE3D' | 'geom_shortestline3d'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 26a8e82191..163d318b04 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -498,6 +498,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -10812,6 +10816,42 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(GeomUnaryUnionLogicalFunction(std::move(arg0))); } /* END CODEGEN PARSER GLUE: GEOM_UNARY_UNION */ + case AntlrSQLParser::GEOM_DIFFERENCE2D: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomDifference2d requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomDifference2dLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_DIFFERENCE2D */ + case AntlrSQLParser::GEOM_INTERSECTION2D: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomIntersection2d requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomIntersection2dLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_INTERSECTION2D */ + case AntlrSQLParser::GEOM_SHORTESTLINE2D: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomShortestline2d requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomShortestline2dLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_SHORTESTLINE2D */ + case AntlrSQLParser::GEOM_SHORTESTLINE3D: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomShortestline3d requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomShortestline3dLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_SHORTESTLINE3D */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 1eec745f6e87ce6003da3fc6245243bd69a37e5a Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 20:17:50 +0200 Subject: [PATCH 78/86] feat(meos): add parameterized geometry transform NES operators returning WKT (W130) Wires GEO_SET_SRID (wkt,srid:U64), GEO_TRANSFORM (wkt,srid_to:U64), GEO_ROUND (wkt,maxdd:U64), and GEOM_BUFFER (wkt,size:F64,params:VARCHAR) as VARCHAR-returning operators. Each physical function parses the WKT input via geom_in, applies the transformation, and serializes the result with geo_as_text. --- .../Meos/GeoRoundLogicalFunction.hpp | 48 +++++++++ .../Meos/GeoSetSridLogicalFunction.hpp | 48 +++++++++ .../Meos/GeoTransformLogicalFunction.hpp | 48 +++++++++ .../Meos/GeomBufferLogicalFunction.hpp | 48 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/GeoRoundLogicalFunction.cpp | 99 +++++++++++++++++ .../Meos/GeoSetSridLogicalFunction.cpp | 99 +++++++++++++++++ .../Meos/GeoTransformLogicalFunction.cpp | 99 +++++++++++++++++ .../Meos/GeomBufferLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/GeoRoundPhysicalFunction.hpp | 32 ++++++ .../Meos/GeoSetSridPhysicalFunction.hpp | 32 ++++++ .../Meos/GeoTransformPhysicalFunction.hpp | 32 ++++++ .../Meos/GeomBufferPhysicalFunction.hpp | 32 ++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../Meos/GeoRoundPhysicalFunction.cpp | 87 +++++++++++++++ .../Meos/GeoSetSridPhysicalFunction.cpp | 87 +++++++++++++++ .../Meos/GeoTransformPhysicalFunction.cpp | 87 +++++++++++++++ .../Meos/GeomBufferPhysicalFunction.cpp | 90 ++++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 41 +++++++ 20 files changed, 1124 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeoRoundLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeoSetSridLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeoTransformLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomBufferLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoRoundLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoSetSridLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoTransformLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomBufferLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoRoundPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoSetSridPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoTransformPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomBufferPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoRoundPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoSetSridPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoTransformPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomBufferPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeoRoundLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoRoundLogicalFunction.hpp new file mode 100644 index 0000000000..978675183c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoRoundLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns a geometry with coordinates rounded to maxdd decimal digits, as WKT. + */ +class GeoRoundLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoRound"; + + GeoRoundLogicalFunction(LogicalFunction wkt, LogicalFunction maxdd); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeoSetSridLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoSetSridLogicalFunction.hpp new file mode 100644 index 0000000000..cc8f75fd1d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoSetSridLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns a geometry with a new SRID assigned, as WKT. + */ +class GeoSetSridLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoSetSrid"; + + GeoSetSridLogicalFunction(LogicalFunction wkt, LogicalFunction srid); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeoTransformLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoTransformLogicalFunction.hpp new file mode 100644 index 0000000000..11fc951f89 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoTransformLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns a geometry reprojected to the target SRID, as WKT. + */ +class GeoTransformLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoTransform"; + + GeoTransformLogicalFunction(LogicalFunction wkt, LogicalFunction srid_to); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomBufferLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomBufferLogicalFunction.hpp new file mode 100644 index 0000000000..bb97748597 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomBufferLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns a geometry buffered by the given size with optional style parameters, as WKT. + */ +class GeomBufferLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomBuffer"; + + GeomBufferLogicalFunction(LogicalFunction wkt, LogicalFunction size, LogicalFunction params); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index fa52006a97..b3467f3f00 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -451,6 +451,10 @@ add_plugin(GeomDifference2d LogicalFunction nes-logical-operators GeomDifference add_plugin(GeomIntersection2d LogicalFunction nes-logical-operators GeomIntersection2dLogicalFunction.cpp) add_plugin(GeomShortestline2d LogicalFunction nes-logical-operators GeomShortestline2dLogicalFunction.cpp) add_plugin(GeomShortestline3d LogicalFunction nes-logical-operators GeomShortestline3dLogicalFunction.cpp) +add_plugin(GeoSetSrid LogicalFunction nes-logical-operators GeoSetSridLogicalFunction.cpp) +add_plugin(GeoTransform LogicalFunction nes-logical-operators GeoTransformLogicalFunction.cpp) +add_plugin(GeoRound LogicalFunction nes-logical-operators GeoRoundLogicalFunction.cpp) +add_plugin(GeomBuffer LogicalFunction nes-logical-operators GeomBufferLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeoRoundLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoRoundLogicalFunction.cpp new file mode 100644 index 0000000000..799e4a137a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoRoundLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoRoundLogicalFunction::GeoRoundLogicalFunction(LogicalFunction wkt, LogicalFunction maxdd) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(maxdd)); +} + +DataType GeoRoundLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoRoundLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoRoundLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoRoundLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeoRoundLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoRoundLogicalFunction::getType() const { return NAME; } + +bool GeoRoundLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoRoundLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoRoundLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "maxdd must be UINT64"); + return withChildren(c); +} + +SerializableFunction GeoRoundLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoRoundLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeoRoundLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeoRoundLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeoSetSridLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoSetSridLogicalFunction.cpp new file mode 100644 index 0000000000..23eb26e5c9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoSetSridLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoSetSridLogicalFunction::GeoSetSridLogicalFunction(LogicalFunction wkt, LogicalFunction srid) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(srid)); +} + +DataType GeoSetSridLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoSetSridLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoSetSridLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoSetSridLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeoSetSridLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoSetSridLogicalFunction::getType() const { return NAME; } + +bool GeoSetSridLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoSetSridLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoSetSridLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "srid must be UINT64"); + return withChildren(c); +} + +SerializableFunction GeoSetSridLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoSetSridLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeoSetSridLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeoSetSridLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeoTransformLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoTransformLogicalFunction.cpp new file mode 100644 index 0000000000..38a442097f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoTransformLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoTransformLogicalFunction::GeoTransformLogicalFunction(LogicalFunction wkt, LogicalFunction srid_to) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(srid_to)); +} + +DataType GeoTransformLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoTransformLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoTransformLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoTransformLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeoTransformLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoTransformLogicalFunction::getType() const { return NAME; } + +bool GeoTransformLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoTransformLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoTransformLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "srid_to must be UINT64"); + return withChildren(c); +} + +SerializableFunction GeoTransformLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoTransformLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeoTransformLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeoTransformLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomBufferLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomBufferLogicalFunction.cpp new file mode 100644 index 0000000000..dd14b1a88a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomBufferLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomBufferLogicalFunction::GeomBufferLogicalFunction(LogicalFunction wkt, LogicalFunction size, LogicalFunction params) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(3); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(size)); + parameters.push_back(std::move(params)); +} + +DataType GeomBufferLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomBufferLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomBufferLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomBufferLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "GeomBufferLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomBufferLogicalFunction::getType() const { return NAME; } + +bool GeomBufferLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomBufferLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomBufferLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "size must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::VARSIZED), "params must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomBufferLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomBufferLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "GeomBufferLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return GeomBufferLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoRoundPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoRoundPhysicalFunction.hpp new file mode 100644 index 0000000000..a71935cf2c --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoRoundPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoRoundPhysicalFunction : public PhysicalFunctionConcept { +public: + GeoRoundPhysicalFunction(PhysicalFunction wkt, PhysicalFunction maxdd); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoSetSridPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoSetSridPhysicalFunction.hpp new file mode 100644 index 0000000000..76be53ae86 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoSetSridPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoSetSridPhysicalFunction : public PhysicalFunctionConcept { +public: + GeoSetSridPhysicalFunction(PhysicalFunction wkt, PhysicalFunction srid); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoTransformPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoTransformPhysicalFunction.hpp new file mode 100644 index 0000000000..6498c79b57 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoTransformPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoTransformPhysicalFunction : public PhysicalFunctionConcept { +public: + GeoTransformPhysicalFunction(PhysicalFunction wkt, PhysicalFunction srid_to); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomBufferPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomBufferPhysicalFunction.hpp new file mode 100644 index 0000000000..896b0c38a3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomBufferPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomBufferPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomBufferPhysicalFunction(PhysicalFunction wkt, PhysicalFunction size, PhysicalFunction params); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index c6aede88f6..75b7c5a802 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -450,6 +450,10 @@ add_plugin(GeomDifference2d PhysicalFunction nes-physical-operators GeomDifferen add_plugin(GeomIntersection2d PhysicalFunction nes-physical-operators GeomIntersection2dPhysicalFunction.cpp) add_plugin(GeomShortestline2d PhysicalFunction nes-physical-operators GeomShortestline2dPhysicalFunction.cpp) add_plugin(GeomShortestline3d PhysicalFunction nes-physical-operators GeomShortestline3dPhysicalFunction.cpp) +add_plugin(GeoSetSrid PhysicalFunction nes-physical-operators GeoSetSridPhysicalFunction.cpp) +add_plugin(GeoTransform PhysicalFunction nes-physical-operators GeoTransformPhysicalFunction.cpp) +add_plugin(GeoRound PhysicalFunction nes-physical-operators GeoRoundPhysicalFunction.cpp) +add_plugin(GeomBuffer PhysicalFunction nes-physical-operators GeomBufferPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/GeoRoundPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoRoundPhysicalFunction.cpp new file mode 100644 index 0000000000..4b8cf3e557 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoRoundPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoRoundPhysicalFunction::GeoRoundPhysicalFunction(PhysicalFunction wkt, PhysicalFunction maxdd) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(maxdd)); +} + +VarVal GeoRoundPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto maxdd = paramFns[1].execute(record, arena).cast>(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, uint64_t maxdd, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geo_round(gs, (int)maxdd); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, maxdd, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoRoundPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeoRoundPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeoRoundPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeoSetSridPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoSetSridPhysicalFunction.cpp new file mode 100644 index 0000000000..b8ff54f049 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoSetSridPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoSetSridPhysicalFunction::GeoSetSridPhysicalFunction(PhysicalFunction wkt, PhysicalFunction srid) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(srid)); +} + +VarVal GeoSetSridPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto srid = paramFns[1].execute(record, arena).cast>(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, uint64_t srid, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geo_set_srid(gs, (int32_t)srid); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, srid, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoSetSridPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeoSetSridPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeoSetSridPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeoTransformPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoTransformPhysicalFunction.cpp new file mode 100644 index 0000000000..704b8afc6a --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoTransformPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoTransformPhysicalFunction::GeoTransformPhysicalFunction(PhysicalFunction wkt, PhysicalFunction srid_to) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(srid_to)); +} + +VarVal GeoTransformPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto srid_to = paramFns[1].execute(record, arena).cast>(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, uint64_t srid_to, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geo_transform(gs, (int32_t)srid_to); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, srid_to, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoTransformPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeoTransformPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeoTransformPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomBufferPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomBufferPhysicalFunction.cpp new file mode 100644 index 0000000000..97942c4995 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomBufferPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomBufferPhysicalFunction::GeomBufferPhysicalFunction(PhysicalFunction wkt, PhysicalFunction size, PhysicalFunction params) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(size)); + paramFns.push_back(std::move(params)); +} + +VarVal GeomBufferPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto size = paramFns[1].execute(record, arena).cast(); + auto params = paramFns[2].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, double size, const char* p, uint32_t psz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz), ps(p, psz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geom_buffer(gs, size, ps.c_str()); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, size, params, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomBufferPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "GeomBufferPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return GeomBufferPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index f6accd04b1..eb009ac65c 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -921,6 +921,10 @@ GEOM_DIFFERENCE2D: 'GEOM_DIFFERENCE2D' | 'geom_difference2d'; GEOM_INTERSECTION2D: 'GEOM_INTERSECTION2D' | 'geom_intersection2d'; GEOM_SHORTESTLINE2D: 'GEOM_SHORTESTLINE2D' | 'geom_shortestline2d'; GEOM_SHORTESTLINE3D: 'GEOM_SHORTESTLINE3D' | 'geom_shortestline3d'; +GEO_SET_SRID: 'GEO_SET_SRID' | 'geo_set_srid'; +GEO_TRANSFORM: 'GEO_TRANSFORM' | 'geo_transform'; +GEO_ROUND: 'GEO_ROUND' | 'geo_round'; +GEOM_BUFFER: 'GEOM_BUFFER' | 'geom_buffer'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 163d318b04..206273efdc 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -502,6 +502,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -10852,6 +10856,43 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(GeomShortestline3dLogicalFunction(std::move(arg0), std::move(arg1))); } /* END CODEGEN PARSER GLUE: GEOM_SHORTESTLINE3D */ + case AntlrSQLParser::GEO_SET_SRID: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeoSetSrid requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeoSetSridLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEO_SET_SRID */ + case AntlrSQLParser::GEO_TRANSFORM: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeoTransform requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeoTransformLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEO_TRANSFORM */ + case AntlrSQLParser::GEO_ROUND: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeoRound requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeoRoundLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEO_ROUND */ + case AntlrSQLParser::GEOM_BUFFER: { + PRECONDITION(ctx->functionParam().size() == 3, + "GeomBuffer requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(GeomBufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: GEOM_BUFFER */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 9441177fee8adb72e0ea742256003c12dc68c6b0 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 20:21:57 +0200 Subject: [PATCH 79/86] feat(meos): add line geometry NES operators (W131) Wires LINE_NUMPOINTS (wkt->FLOAT64), LINE_LOCATE_POINT (wkt1,wkt2->FLOAT64), LINE_INTERPOLATE_POINT (wkt,frac:F64,repeat:U64->VARCHAR), and LINE_SUBSTRING (wkt,from:F64,to:F64->VARCHAR). FLOAT64-returning ops call line_numpoints/ line_locate_point directly; VARCHAR-returning ops parse via geom_in and serialize results with geo_as_text. --- .../LineInterpolatePointLogicalFunction.hpp | 48 +++++++++ .../Meos/LineLocatePointLogicalFunction.hpp | 48 +++++++++ .../Meos/LineNumpointsLogicalFunction.hpp | 48 +++++++++ .../Meos/LineSubstringLogicalFunction.hpp | 48 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../LineInterpolatePointLogicalFunction.cpp | 102 ++++++++++++++++++ .../Meos/LineLocatePointLogicalFunction.cpp | 99 +++++++++++++++++ .../Meos/LineNumpointsLogicalFunction.cpp | 96 +++++++++++++++++ .../Meos/LineSubstringLogicalFunction.cpp | 102 ++++++++++++++++++ .../LineInterpolatePointPhysicalFunction.hpp | 32 ++++++ .../Meos/LineLocatePointPhysicalFunction.hpp | 32 ++++++ .../Meos/LineNumpointsPhysicalFunction.hpp | 32 ++++++ .../Meos/LineSubstringPhysicalFunction.hpp | 32 ++++++ .../src/Functions/Meos/CMakeLists.txt | 4 + .../LineInterpolatePointPhysicalFunction.cpp | 90 ++++++++++++++++ .../Meos/LineLocatePointPhysicalFunction.cpp | 76 +++++++++++++ .../Meos/LineNumpointsPhysicalFunction.cpp | 71 ++++++++++++ .../Meos/LineSubstringPhysicalFunction.cpp | 90 ++++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 6 +- .../src/AntlrSQLQueryPlanCreator.cpp | 41 +++++++ 20 files changed, 1100 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/LineInterpolatePointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/LineLocatePointLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/LineNumpointsLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/LineSubstringLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/LineInterpolatePointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/LineLocatePointLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/LineNumpointsLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/LineSubstringLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/LineInterpolatePointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/LineLocatePointPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/LineNumpointsPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/LineSubstringPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/LineInterpolatePointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/LineLocatePointPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/LineNumpointsPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/LineSubstringPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/LineInterpolatePointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/LineInterpolatePointLogicalFunction.hpp new file mode 100644 index 0000000000..51ef5888cd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/LineInterpolatePointLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the point (or multi-point if repeat=1) interpolated at the given fraction along a line. + */ +class LineInterpolatePointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "LineInterpolatePoint"; + + LineInterpolatePointLogicalFunction(LogicalFunction wkt, LogicalFunction frac, LogicalFunction repeat); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/LineLocatePointLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/LineLocatePointLogicalFunction.hpp new file mode 100644 index 0000000000..9a09b8181d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/LineLocatePointLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the fractional location (0–1) of the closest point on the line to a point. + */ +class LineLocatePointLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "LineLocatePoint"; + + LineLocatePointLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/LineNumpointsLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/LineNumpointsLogicalFunction.hpp new file mode 100644 index 0000000000..f3aa1e814f --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/LineNumpointsLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the number of points in a linestring. + */ +class LineNumpointsLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "LineNumpoints"; + + LineNumpointsLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/LineSubstringLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/LineSubstringLogicalFunction.hpp new file mode 100644 index 0000000000..938bc97d69 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/LineSubstringLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the portion of a linestring between fractional positions from and to. + */ +class LineSubstringLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "LineSubstring"; + + LineSubstringLogicalFunction(LogicalFunction wkt, LogicalFunction from_f, LogicalFunction to_f); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index b3467f3f00..749b869b99 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -455,6 +455,10 @@ add_plugin(GeoSetSrid LogicalFunction nes-logical-operators GeoSetSridLogicalFun add_plugin(GeoTransform LogicalFunction nes-logical-operators GeoTransformLogicalFunction.cpp) add_plugin(GeoRound LogicalFunction nes-logical-operators GeoRoundLogicalFunction.cpp) add_plugin(GeomBuffer LogicalFunction nes-logical-operators GeomBufferLogicalFunction.cpp) +add_plugin(LineNumpoints LogicalFunction nes-logical-operators LineNumpointsLogicalFunction.cpp) +add_plugin(LineLocatePoint LogicalFunction nes-logical-operators LineLocatePointLogicalFunction.cpp) +add_plugin(LineInterpolatePoint LogicalFunction nes-logical-operators LineInterpolatePointLogicalFunction.cpp) +add_plugin(LineSubstring LogicalFunction nes-logical-operators LineSubstringLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/LineInterpolatePointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/LineInterpolatePointLogicalFunction.cpp new file mode 100644 index 0000000000..92f79d391a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/LineInterpolatePointLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +LineInterpolatePointLogicalFunction::LineInterpolatePointLogicalFunction(LogicalFunction wkt, LogicalFunction frac, LogicalFunction repeat) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(3); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(frac)); + parameters.push_back(std::move(repeat)); +} + +DataType LineInterpolatePointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction LineInterpolatePointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector LineInterpolatePointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction LineInterpolatePointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "LineInterpolatePointLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view LineInterpolatePointLogicalFunction::getType() const { return NAME; } + +bool LineInterpolatePointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string LineInterpolatePointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction LineInterpolatePointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "frac must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "repeat must be UINT64"); + return withChildren(c); +} + +SerializableFunction LineInterpolatePointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterLineInterpolatePointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "LineInterpolatePointLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return LineInterpolatePointLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/LineLocatePointLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/LineLocatePointLogicalFunction.cpp new file mode 100644 index 0000000000..3140e7b1c5 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/LineLocatePointLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +LineLocatePointLogicalFunction::LineLocatePointLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType LineLocatePointLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction LineLocatePointLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector LineLocatePointLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction LineLocatePointLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "LineLocatePointLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view LineLocatePointLogicalFunction::getType() const { return NAME; } + +bool LineLocatePointLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string LineLocatePointLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction LineLocatePointLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction LineLocatePointLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterLineLocatePointLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "LineLocatePointLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return LineLocatePointLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/LineNumpointsLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/LineNumpointsLogicalFunction.cpp new file mode 100644 index 0000000000..66ff6308ca --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/LineNumpointsLogicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +LineNumpointsLogicalFunction::LineNumpointsLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType LineNumpointsLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction LineNumpointsLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector LineNumpointsLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction LineNumpointsLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "LineNumpointsLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view LineNumpointsLogicalFunction::getType() const { return NAME; } + +bool LineNumpointsLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string LineNumpointsLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction LineNumpointsLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction LineNumpointsLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterLineNumpointsLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "LineNumpointsLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return LineNumpointsLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/LineSubstringLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/LineSubstringLogicalFunction.cpp new file mode 100644 index 0000000000..a3fe7ed33d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/LineSubstringLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +LineSubstringLogicalFunction::LineSubstringLogicalFunction(LogicalFunction wkt, LogicalFunction from_f, LogicalFunction to_f) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(3); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(from_f)); + parameters.push_back(std::move(to_f)); +} + +DataType LineSubstringLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction LineSubstringLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector LineSubstringLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction LineSubstringLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "LineSubstringLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view LineSubstringLogicalFunction::getType() const { return NAME; } + +bool LineSubstringLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string LineSubstringLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction LineSubstringLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "from_f must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "to_f must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction LineSubstringLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterLineSubstringLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "LineSubstringLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return LineSubstringLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/LineInterpolatePointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/LineInterpolatePointPhysicalFunction.hpp new file mode 100644 index 0000000000..b619a62647 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/LineInterpolatePointPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class LineInterpolatePointPhysicalFunction : public PhysicalFunctionConcept { +public: + LineInterpolatePointPhysicalFunction(PhysicalFunction wkt, PhysicalFunction frac, PhysicalFunction repeat); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/LineLocatePointPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/LineLocatePointPhysicalFunction.hpp new file mode 100644 index 0000000000..93adb2a189 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/LineLocatePointPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class LineLocatePointPhysicalFunction : public PhysicalFunctionConcept { +public: + LineLocatePointPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/LineNumpointsPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/LineNumpointsPhysicalFunction.hpp new file mode 100644 index 0000000000..1a03421945 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/LineNumpointsPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class LineNumpointsPhysicalFunction : public PhysicalFunctionConcept { +public: + LineNumpointsPhysicalFunction(PhysicalFunction wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/LineSubstringPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/LineSubstringPhysicalFunction.hpp new file mode 100644 index 0000000000..23994e81d2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/LineSubstringPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class LineSubstringPhysicalFunction : public PhysicalFunctionConcept { +public: + LineSubstringPhysicalFunction(PhysicalFunction wkt, PhysicalFunction from_f, PhysicalFunction to_f); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 75b7c5a802..2becd02bb2 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -454,6 +454,10 @@ add_plugin(GeoSetSrid PhysicalFunction nes-physical-operators GeoSetSridPhysical add_plugin(GeoTransform PhysicalFunction nes-physical-operators GeoTransformPhysicalFunction.cpp) add_plugin(GeoRound PhysicalFunction nes-physical-operators GeoRoundPhysicalFunction.cpp) add_plugin(GeomBuffer PhysicalFunction nes-physical-operators GeomBufferPhysicalFunction.cpp) +add_plugin(LineNumpoints PhysicalFunction nes-physical-operators LineNumpointsPhysicalFunction.cpp) +add_plugin(LineLocatePoint PhysicalFunction nes-physical-operators LineLocatePointPhysicalFunction.cpp) +add_plugin(LineInterpolatePoint PhysicalFunction nes-physical-operators LineInterpolatePointPhysicalFunction.cpp) +add_plugin(LineSubstring PhysicalFunction nes-physical-operators LineSubstringPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/LineInterpolatePointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/LineInterpolatePointPhysicalFunction.cpp new file mode 100644 index 0000000000..e1bd9be8a5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/LineInterpolatePointPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +LineInterpolatePointPhysicalFunction::LineInterpolatePointPhysicalFunction(PhysicalFunction wkt, PhysicalFunction frac, PhysicalFunction repeat) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(frac)); + paramFns.push_back(std::move(repeat)); +} + +VarVal LineInterpolatePointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto frac = paramFns[1].execute(record, arena).cast(); + auto repeat = paramFns[2].execute(record, arena).cast>(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, double frac, uint64_t repeat, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = line_interpolate_point(gs, frac, (bool)repeat); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, frac, repeat, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterLineInterpolatePointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "LineInterpolatePointPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return LineInterpolatePointPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/LineLocatePointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/LineLocatePointPhysicalFunction.cpp new file mode 100644 index 0000000000..22cb999698 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/LineLocatePointPhysicalFunction.cpp @@ -0,0 +1,76 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +LineLocatePointPhysicalFunction::LineLocatePointPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); +} + +VarVal LineLocatePointPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + double r = line_locate_point(gs1, gs2); + free(gs1); free(gs2); + return r; + } catch (const std::exception&) { return 0.0; } + }, + wkt1, wkt2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterLineLocatePointPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "LineLocatePointPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return LineLocatePointPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/LineNumpointsPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/LineNumpointsPhysicalFunction.cpp new file mode 100644 index 0000000000..60c8c90294 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/LineNumpointsPhysicalFunction.cpp @@ -0,0 +1,71 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +LineNumpointsPhysicalFunction::LineNumpointsPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal LineNumpointsPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* w, uint32_t wsz) -> double -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0.0; + int n = line_numpoints(gs); + free(gs); + return (double)n; + } catch (const std::exception&) { return 0.0; } + }, + wkt); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterLineNumpointsPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "LineNumpointsPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return LineNumpointsPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/LineSubstringPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/LineSubstringPhysicalFunction.cpp new file mode 100644 index 0000000000..94674a3bc2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/LineSubstringPhysicalFunction.cpp @@ -0,0 +1,90 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +LineSubstringPhysicalFunction::LineSubstringPhysicalFunction(PhysicalFunction wkt, PhysicalFunction from_f, PhysicalFunction to_f) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(from_f)); + paramFns.push_back(std::move(to_f)); +} + +VarVal LineSubstringPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto from_f = paramFns[1].execute(record, arena).cast(); + auto to_f = paramFns[2].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, double from_f, double to_f, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = line_substring(gs, from_f, to_f); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, from_f, to_f, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterLineSubstringPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "LineSubstringPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return LineSubstringPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index eb009ac65c..d26bb195ca 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -925,6 +925,10 @@ GEO_SET_SRID: 'GEO_SET_SRID' | 'geo_set_srid'; GEO_TRANSFORM: 'GEO_TRANSFORM' | 'geo_transform'; GEO_ROUND: 'GEO_ROUND' | 'geo_round'; GEOM_BUFFER: 'GEOM_BUFFER' | 'geom_buffer'; +LINE_NUMPOINTS: 'LINE_NUMPOINTS' | 'line_numpoints'; +LINE_LOCATE_POINT: 'LINE_LOCATE_POINT' | 'line_locate_point'; +LINE_INTERPOLATE_POINT: 'LINE_INTERPOLATE_POINT' | 'line_interpolate_point'; +LINE_SUBSTRING: 'LINE_SUBSTRING' | 'line_substring'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 206273efdc..12db65ad9e 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -506,6 +506,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -10893,6 +10897,43 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(GeomBufferLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); } /* END CODEGEN PARSER GLUE: GEOM_BUFFER */ + case AntlrSQLParser::LINE_NUMPOINTS: { + PRECONDITION(ctx->functionParam().size() == 1, + "LineNumpoints requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(LineNumpointsLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: LINE_NUMPOINTS */ + case AntlrSQLParser::LINE_LOCATE_POINT: { + PRECONDITION(ctx->functionParam().size() == 2, + "LineLocatePoint requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(LineLocatePointLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: LINE_LOCATE_POINT */ + case AntlrSQLParser::LINE_INTERPOLATE_POINT: { + PRECONDITION(ctx->functionParam().size() == 3, + "LineInterpolatePoint requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(LineInterpolatePointLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: LINE_INTERPOLATE_POINT */ + case AntlrSQLParser::LINE_SUBSTRING: { + PRECONDITION(ctx->functionParam().size() == 3, + "LineSubstring requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(LineSubstringLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: LINE_SUBSTRING */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From cfbcc0f44543395b6fb593ec6c55ee8c28b4a1ff Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 20:22:08 +0200 Subject: [PATCH 80/86] feat(meos): add geometry constructor and conversion NES operators (W132) Wires GEOM_POINT_MAKE2D/3DZ and GEOG_POINT_MAKE2D/3DZ (srid:U64,x,y[,z]:F64-> VARCHAR), GEOM_TO_GEOG and GEOG_TO_GEOM (wkt:VARCHAR->VARCHAR), and GEOG_CENTROID (wkt:VARCHAR,use_spheroid:U64->VARCHAR). Constructor ops call geompoint_make2d/3dz and geogpoint_make2d/3dz directly; conversion and centroid ops parse via geom_in/geog_in and serialize with geo_as_text. --- .../Meos/GeogCentroidLogicalFunction.hpp | 48 ++++++++ .../Meos/GeogPointMake2dLogicalFunction.hpp | 48 ++++++++ .../Meos/GeogPointMake3dzLogicalFunction.hpp | 48 ++++++++ .../Meos/GeogToGeomLogicalFunction.hpp | 48 ++++++++ .../Meos/GeomPointMake2dLogicalFunction.hpp | 48 ++++++++ .../Meos/GeomPointMake3dzLogicalFunction.hpp | 48 ++++++++ .../Meos/GeomToGeogLogicalFunction.hpp | 48 ++++++++ .../src/Functions/Meos/CMakeLists.txt | 7 ++ .../Meos/GeogCentroidLogicalFunction.cpp | 99 +++++++++++++++++ .../Meos/GeogPointMake2dLogicalFunction.cpp | 102 +++++++++++++++++ .../Meos/GeogPointMake3dzLogicalFunction.cpp | 105 ++++++++++++++++++ .../Meos/GeogToGeomLogicalFunction.cpp | 96 ++++++++++++++++ .../Meos/GeomPointMake2dLogicalFunction.cpp | 102 +++++++++++++++++ .../Meos/GeomPointMake3dzLogicalFunction.cpp | 105 ++++++++++++++++++ .../Meos/GeomToGeogLogicalFunction.cpp | 96 ++++++++++++++++ .../Meos/GeogCentroidPhysicalFunction.hpp | 32 ++++++ .../Meos/GeogPointMake2dPhysicalFunction.hpp | 32 ++++++ .../Meos/GeogPointMake3dzPhysicalFunction.hpp | 32 ++++++ .../Meos/GeogToGeomPhysicalFunction.hpp | 32 ++++++ .../Meos/GeomPointMake2dPhysicalFunction.hpp | 32 ++++++ .../Meos/GeomPointMake3dzPhysicalFunction.hpp | 32 ++++++ .../Meos/GeomToGeogPhysicalFunction.hpp | 32 ++++++ .../src/Functions/Meos/CMakeLists.txt | 7 ++ .../Meos/GeogCentroidPhysicalFunction.cpp | 87 +++++++++++++++ .../Meos/GeogPointMake2dPhysicalFunction.cpp | 86 ++++++++++++++ .../Meos/GeogPointMake3dzPhysicalFunction.cpp | 89 +++++++++++++++ .../Meos/GeogToGeomPhysicalFunction.cpp | 84 ++++++++++++++ .../Meos/GeomPointMake2dPhysicalFunction.cpp | 86 ++++++++++++++ .../Meos/GeomPointMake3dzPhysicalFunction.cpp | 89 +++++++++++++++ .../Meos/GeomToGeogPhysicalFunction.cpp | 84 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 9 +- .../src/AntlrSQLQueryPlanCreator.cpp | 74 ++++++++++++ 32 files changed, 1966 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeogCentroidLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeogPointMake2dLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeogPointMake3dzLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeogToGeomLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomPointMake2dLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomPointMake3dzLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomToGeogLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeogCentroidLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeogPointMake2dLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeogPointMake3dzLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeogToGeomLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomPointMake2dLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomPointMake3dzLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomToGeogLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeogCentroidPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeogPointMake2dPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeogPointMake3dzPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeogToGeomPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomPointMake2dPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomPointMake3dzPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomToGeogPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeogCentroidPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeogPointMake2dPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeogPointMake3dzPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeogToGeomPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomPointMake2dPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomPointMake3dzPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomToGeogPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeogCentroidLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeogCentroidLogicalFunction.hpp new file mode 100644 index 0000000000..535f5feebf --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeogCentroidLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the centroid of a geography (use_spheroid=1 for spheroid, 0 for sphere) as WKT. + */ +class GeogCentroidLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeogCentroid"; + + GeogCentroidLogicalFunction(LogicalFunction wkt, LogicalFunction use_spheroid); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeogPointMake2dLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeogPointMake2dLogicalFunction.hpp new file mode 100644 index 0000000000..d5a5932c88 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeogPointMake2dLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Constructs a 2D geography point from SRID, x, and y as WKT. + */ +class GeogPointMake2dLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeogPointMake2d"; + + GeogPointMake2dLogicalFunction(LogicalFunction srid, LogicalFunction x, LogicalFunction y); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeogPointMake3dzLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeogPointMake3dzLogicalFunction.hpp new file mode 100644 index 0000000000..b3f4f1e9bb --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeogPointMake3dzLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Constructs a 3DZ geography point from SRID, x, y, and z as WKT. + */ +class GeogPointMake3dzLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeogPointMake3dz"; + + GeogPointMake3dzLogicalFunction(LogicalFunction srid, LogicalFunction x, LogicalFunction y, LogicalFunction z); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeogToGeomLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeogToGeomLogicalFunction.hpp new file mode 100644 index 0000000000..7b476ff5a1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeogToGeomLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Converts a geography to a geometry as WKT. + */ +class GeogToGeomLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeogToGeom"; + + GeogToGeomLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomPointMake2dLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomPointMake2dLogicalFunction.hpp new file mode 100644 index 0000000000..cea1afe7e1 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomPointMake2dLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Constructs a 2D geometry point from SRID, x, and y as WKT. + */ +class GeomPointMake2dLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomPointMake2d"; + + GeomPointMake2dLogicalFunction(LogicalFunction srid, LogicalFunction x, LogicalFunction y); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomPointMake3dzLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomPointMake3dzLogicalFunction.hpp new file mode 100644 index 0000000000..1415b13d98 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomPointMake3dzLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Constructs a 3DZ geometry point from SRID, x, y, and z as WKT. + */ +class GeomPointMake3dzLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomPointMake3dz"; + + GeomPointMake3dzLogicalFunction(LogicalFunction srid, LogicalFunction x, LogicalFunction y, LogicalFunction z); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomToGeogLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomToGeogLogicalFunction.hpp new file mode 100644 index 0000000000..f9cef59303 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomToGeogLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Converts a geometry to a geography as WKT. + */ +class GeomToGeogLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomToGeog"; + + GeomToGeogLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 749b869b99..505a3df92b 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -459,6 +459,13 @@ add_plugin(LineNumpoints LogicalFunction nes-logical-operators LineNumpointsLogi add_plugin(LineLocatePoint LogicalFunction nes-logical-operators LineLocatePointLogicalFunction.cpp) add_plugin(LineInterpolatePoint LogicalFunction nes-logical-operators LineInterpolatePointLogicalFunction.cpp) add_plugin(LineSubstring LogicalFunction nes-logical-operators LineSubstringLogicalFunction.cpp) +add_plugin(GeomPointMake2d LogicalFunction nes-logical-operators GeomPointMake2dLogicalFunction.cpp) +add_plugin(GeomPointMake3dz LogicalFunction nes-logical-operators GeomPointMake3dzLogicalFunction.cpp) +add_plugin(GeogPointMake2d LogicalFunction nes-logical-operators GeogPointMake2dLogicalFunction.cpp) +add_plugin(GeogPointMake3dz LogicalFunction nes-logical-operators GeogPointMake3dzLogicalFunction.cpp) +add_plugin(GeomToGeog LogicalFunction nes-logical-operators GeomToGeogLogicalFunction.cpp) +add_plugin(GeogToGeom LogicalFunction nes-logical-operators GeogToGeomLogicalFunction.cpp) +add_plugin(GeogCentroid LogicalFunction nes-logical-operators GeogCentroidLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeogCentroidLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeogCentroidLogicalFunction.cpp new file mode 100644 index 0000000000..6d434f8684 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeogCentroidLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeogCentroidLogicalFunction::GeogCentroidLogicalFunction(LogicalFunction wkt, LogicalFunction use_spheroid) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(use_spheroid)); +} + +DataType GeogCentroidLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeogCentroidLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeogCentroidLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeogCentroidLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeogCentroidLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeogCentroidLogicalFunction::getType() const { return NAME; } + +bool GeogCentroidLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeogCentroidLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeogCentroidLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "use_spheroid must be UINT64"); + return withChildren(c); +} + +SerializableFunction GeogCentroidLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeogCentroidLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeogCentroidLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeogCentroidLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeogPointMake2dLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeogPointMake2dLogicalFunction.cpp new file mode 100644 index 0000000000..b0f2357278 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeogPointMake2dLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeogPointMake2dLogicalFunction::GeogPointMake2dLogicalFunction(LogicalFunction srid, LogicalFunction x, LogicalFunction y) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(3); + parameters.push_back(std::move(srid)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); +} + +DataType GeogPointMake2dLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeogPointMake2dLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeogPointMake2dLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeogPointMake2dLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "GeogPointMake2dLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeogPointMake2dLogicalFunction::getType() const { return NAME; } + +bool GeogPointMake2dLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeogPointMake2dLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeogPointMake2dLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "srid must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction GeogPointMake2dLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeogPointMake2dLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "GeogPointMake2dLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return GeogPointMake2dLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeogPointMake3dzLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeogPointMake3dzLogicalFunction.cpp new file mode 100644 index 0000000000..23c43682f8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeogPointMake3dzLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeogPointMake3dzLogicalFunction::GeogPointMake3dzLogicalFunction(LogicalFunction srid, LogicalFunction x, LogicalFunction y, LogicalFunction z) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(4); + parameters.push_back(std::move(srid)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(z)); +} + +DataType GeogPointMake3dzLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeogPointMake3dzLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeogPointMake3dzLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeogPointMake3dzLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "GeogPointMake3dzLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeogPointMake3dzLogicalFunction::getType() const { return NAME; } + +bool GeogPointMake3dzLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeogPointMake3dzLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeogPointMake3dzLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "srid must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "z must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction GeogPointMake3dzLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeogPointMake3dzLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "GeogPointMake3dzLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return GeogPointMake3dzLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeogToGeomLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeogToGeomLogicalFunction.cpp new file mode 100644 index 0000000000..a028f92f75 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeogToGeomLogicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeogToGeomLogicalFunction::GeogToGeomLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeogToGeomLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeogToGeomLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeogToGeomLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeogToGeomLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeogToGeomLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeogToGeomLogicalFunction::getType() const { return NAME; } + +bool GeogToGeomLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeogToGeomLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeogToGeomLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeogToGeomLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeogToGeomLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeogToGeomLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return GeogToGeomLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomPointMake2dLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomPointMake2dLogicalFunction.cpp new file mode 100644 index 0000000000..57b066a14f --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomPointMake2dLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomPointMake2dLogicalFunction::GeomPointMake2dLogicalFunction(LogicalFunction srid, LogicalFunction x, LogicalFunction y) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(3); + parameters.push_back(std::move(srid)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); +} + +DataType GeomPointMake2dLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomPointMake2dLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomPointMake2dLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomPointMake2dLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "GeomPointMake2dLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomPointMake2dLogicalFunction::getType() const { return NAME; } + +bool GeomPointMake2dLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomPointMake2dLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomPointMake2dLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "srid must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction GeomPointMake2dLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomPointMake2dLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "GeomPointMake2dLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return GeomPointMake2dLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomPointMake3dzLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomPointMake3dzLogicalFunction.cpp new file mode 100644 index 0000000000..065192b0a7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomPointMake3dzLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomPointMake3dzLogicalFunction::GeomPointMake3dzLogicalFunction(LogicalFunction srid, LogicalFunction x, LogicalFunction y, LogicalFunction z) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(4); + parameters.push_back(std::move(srid)); + parameters.push_back(std::move(x)); + parameters.push_back(std::move(y)); + parameters.push_back(std::move(z)); +} + +DataType GeomPointMake3dzLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomPointMake3dzLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomPointMake3dzLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomPointMake3dzLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "GeomPointMake3dzLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomPointMake3dzLogicalFunction::getType() const { return NAME; } + +bool GeomPointMake3dzLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomPointMake3dzLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomPointMake3dzLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "srid must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "x must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::FLOAT64), "y must be FLOAT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "z must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction GeomPointMake3dzLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomPointMake3dzLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "GeomPointMake3dzLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return GeomPointMake3dzLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomToGeogLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomToGeogLogicalFunction.cpp new file mode 100644 index 0000000000..c00d34698b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomToGeogLogicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomToGeogLogicalFunction::GeomToGeogLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeomToGeogLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomToGeogLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomToGeogLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomToGeogLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeomToGeogLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomToGeogLogicalFunction::getType() const { return NAME; } + +bool GeomToGeogLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomToGeogLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomToGeogLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomToGeogLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomToGeogLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeomToGeogLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return GeomToGeogLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeogCentroidPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeogCentroidPhysicalFunction.hpp new file mode 100644 index 0000000000..a92650b0b0 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeogCentroidPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeogCentroidPhysicalFunction : public PhysicalFunctionConcept { +public: + GeogCentroidPhysicalFunction(PhysicalFunction wkt, PhysicalFunction use_spheroid); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeogPointMake2dPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeogPointMake2dPhysicalFunction.hpp new file mode 100644 index 0000000000..6b47a161b3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeogPointMake2dPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeogPointMake2dPhysicalFunction : public PhysicalFunctionConcept { +public: + GeogPointMake2dPhysicalFunction(PhysicalFunction srid, PhysicalFunction x, PhysicalFunction y); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeogPointMake3dzPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeogPointMake3dzPhysicalFunction.hpp new file mode 100644 index 0000000000..274fac0b04 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeogPointMake3dzPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeogPointMake3dzPhysicalFunction : public PhysicalFunctionConcept { +public: + GeogPointMake3dzPhysicalFunction(PhysicalFunction srid, PhysicalFunction x, PhysicalFunction y, PhysicalFunction z); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeogToGeomPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeogToGeomPhysicalFunction.hpp new file mode 100644 index 0000000000..cb732983de --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeogToGeomPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeogToGeomPhysicalFunction : public PhysicalFunctionConcept { +public: + GeogToGeomPhysicalFunction(PhysicalFunction wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomPointMake2dPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomPointMake2dPhysicalFunction.hpp new file mode 100644 index 0000000000..2bfe851c1f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomPointMake2dPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomPointMake2dPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomPointMake2dPhysicalFunction(PhysicalFunction srid, PhysicalFunction x, PhysicalFunction y); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomPointMake3dzPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomPointMake3dzPhysicalFunction.hpp new file mode 100644 index 0000000000..24deab91b2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomPointMake3dzPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomPointMake3dzPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomPointMake3dzPhysicalFunction(PhysicalFunction srid, PhysicalFunction x, PhysicalFunction y, PhysicalFunction z); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomToGeogPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomToGeogPhysicalFunction.hpp new file mode 100644 index 0000000000..6fa9c50df7 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomToGeogPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomToGeogPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomToGeogPhysicalFunction(PhysicalFunction wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 2becd02bb2..254b925187 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -458,6 +458,13 @@ add_plugin(LineNumpoints PhysicalFunction nes-physical-operators LineNumpointsPh add_plugin(LineLocatePoint PhysicalFunction nes-physical-operators LineLocatePointPhysicalFunction.cpp) add_plugin(LineInterpolatePoint PhysicalFunction nes-physical-operators LineInterpolatePointPhysicalFunction.cpp) add_plugin(LineSubstring PhysicalFunction nes-physical-operators LineSubstringPhysicalFunction.cpp) +add_plugin(GeomPointMake2d PhysicalFunction nes-physical-operators GeomPointMake2dPhysicalFunction.cpp) +add_plugin(GeomPointMake3dz PhysicalFunction nes-physical-operators GeomPointMake3dzPhysicalFunction.cpp) +add_plugin(GeogPointMake2d PhysicalFunction nes-physical-operators GeogPointMake2dPhysicalFunction.cpp) +add_plugin(GeogPointMake3dz PhysicalFunction nes-physical-operators GeogPointMake3dzPhysicalFunction.cpp) +add_plugin(GeomToGeog PhysicalFunction nes-physical-operators GeomToGeogPhysicalFunction.cpp) +add_plugin(GeogToGeom PhysicalFunction nes-physical-operators GeogToGeomPhysicalFunction.cpp) +add_plugin(GeogCentroid PhysicalFunction nes-physical-operators GeogCentroidPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/GeogCentroidPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeogCentroidPhysicalFunction.cpp new file mode 100644 index 0000000000..5c15715054 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeogCentroidPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeogCentroidPhysicalFunction::GeogCentroidPhysicalFunction(PhysicalFunction wkt, PhysicalFunction use_spheroid) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(use_spheroid)); +} + +VarVal GeogCentroidPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto use_spheroid = paramFns[1].execute(record, arena).cast>(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, uint64_t use_spheroid, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geog_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geog_centroid(gs, (bool)use_spheroid); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, use_spheroid, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeogCentroidPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeogCentroidPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeogCentroidPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeogPointMake2dPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeogPointMake2dPhysicalFunction.cpp new file mode 100644 index 0000000000..36dc8999ae --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeogPointMake2dPhysicalFunction.cpp @@ -0,0 +1,86 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeogPointMake2dPhysicalFunction::GeogPointMake2dPhysicalFunction(PhysicalFunction srid, PhysicalFunction x, PhysicalFunction y) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(srid)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); +} + +VarVal GeogPointMake2dPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto srid = paramFns[0].execute(record, arena).cast>(); + auto x = paramFns[1].execute(record, arena).cast(); + auto y = paramFns[2].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](uint64_t srid, double x, double y, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + GSERIALIZED* result = geogpoint_make2d((int32_t)srid, x, y); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + srid, x, y, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeogPointMake2dPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "GeogPointMake2dPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return GeogPointMake2dPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeogPointMake3dzPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeogPointMake3dzPhysicalFunction.cpp new file mode 100644 index 0000000000..4011670d90 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeogPointMake3dzPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeogPointMake3dzPhysicalFunction::GeogPointMake3dzPhysicalFunction(PhysicalFunction srid, PhysicalFunction x, PhysicalFunction y, PhysicalFunction z) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(srid)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(z)); +} + +VarVal GeogPointMake3dzPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto srid = paramFns[0].execute(record, arena).cast>(); + auto x = paramFns[1].execute(record, arena).cast(); + auto y = paramFns[2].execute(record, arena).cast(); + auto z = paramFns[3].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](uint64_t srid, double x, double y, double z, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + GSERIALIZED* result = geogpoint_make3dz((int32_t)srid, x, y, z); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + srid, x, y, z, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeogPointMake3dzPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "GeogPointMake3dzPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return GeogPointMake3dzPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeogToGeomPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeogToGeomPhysicalFunction.cpp new file mode 100644 index 0000000000..9f20aaa671 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeogToGeomPhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeogToGeomPhysicalFunction::GeogToGeomPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeogToGeomPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geog_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geog_to_geom(gs); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeogToGeomPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeogToGeomPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return GeogToGeomPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomPointMake2dPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomPointMake2dPhysicalFunction.cpp new file mode 100644 index 0000000000..edbcad0082 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomPointMake2dPhysicalFunction.cpp @@ -0,0 +1,86 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomPointMake2dPhysicalFunction::GeomPointMake2dPhysicalFunction(PhysicalFunction srid, PhysicalFunction x, PhysicalFunction y) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(srid)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); +} + +VarVal GeomPointMake2dPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto srid = paramFns[0].execute(record, arena).cast>(); + auto x = paramFns[1].execute(record, arena).cast(); + auto y = paramFns[2].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](uint64_t srid, double x, double y, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + GSERIALIZED* result = geompoint_make2d((int32_t)srid, x, y); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + srid, x, y, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomPointMake2dPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "GeomPointMake2dPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return GeomPointMake2dPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomPointMake3dzPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomPointMake3dzPhysicalFunction.cpp new file mode 100644 index 0000000000..4b233579da --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomPointMake3dzPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomPointMake3dzPhysicalFunction::GeomPointMake3dzPhysicalFunction(PhysicalFunction srid, PhysicalFunction x, PhysicalFunction y, PhysicalFunction z) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(srid)); + paramFns.push_back(std::move(x)); + paramFns.push_back(std::move(y)); + paramFns.push_back(std::move(z)); +} + +VarVal GeomPointMake3dzPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto srid = paramFns[0].execute(record, arena).cast>(); + auto x = paramFns[1].execute(record, arena).cast(); + auto y = paramFns[2].execute(record, arena).cast(); + auto z = paramFns[3].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](uint64_t srid, double x, double y, double z, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + GSERIALIZED* result = geompoint_make3dz((int32_t)srid, x, y, z); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + srid, x, y, z, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomPointMake3dzPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "GeomPointMake3dzPhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return GeomPointMake3dzPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomToGeogPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomToGeogPhysicalFunction.cpp new file mode 100644 index 0000000000..1e1731b9b5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomToGeogPhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomToGeogPhysicalFunction::GeomToGeogPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeomToGeogPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geom_to_geog(gs); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomToGeogPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeomToGeogPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return GeomToGeogPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index d26bb195ca..72fdf8a158 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_POINT_MAKE2D | GEOM_POINT_MAKE3DZ | GEOG_POINT_MAKE2D | GEOG_POINT_MAKE3DZ | GEOM_TO_GEOG | GEOG_TO_GEOM | GEOG_CENTROID | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -929,6 +929,13 @@ LINE_NUMPOINTS: 'LINE_NUMPOINTS' | 'line_numpoints'; LINE_LOCATE_POINT: 'LINE_LOCATE_POINT' | 'line_locate_point'; LINE_INTERPOLATE_POINT: 'LINE_INTERPOLATE_POINT' | 'line_interpolate_point'; LINE_SUBSTRING: 'LINE_SUBSTRING' | 'line_substring'; +GEOM_POINT_MAKE2D: 'GEOM_POINT_MAKE2D' | 'geompoint_make2d'; +GEOM_POINT_MAKE3DZ: 'GEOM_POINT_MAKE3DZ' | 'geompoint_make3dz'; +GEOG_POINT_MAKE2D: 'GEOG_POINT_MAKE2D' | 'geogpoint_make2d'; +GEOG_POINT_MAKE3DZ: 'GEOG_POINT_MAKE3DZ' | 'geogpoint_make3dz'; +GEOM_TO_GEOG: 'GEOM_TO_GEOG' | 'geom_to_geog'; +GEOG_TO_GEOM: 'GEOG_TO_GEOM' | 'geog_to_geom'; +GEOG_CENTROID: 'GEOG_CENTROID' | 'geog_centroid'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 12db65ad9e..bde0966bf6 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -510,6 +510,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -10934,6 +10941,73 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(LineSubstringLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); } /* END CODEGEN PARSER GLUE: LINE_SUBSTRING */ + case AntlrSQLParser::GEOM_POINT_MAKE2D: { + PRECONDITION(ctx->functionParam().size() == 3, + "GeomPointMake2d requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(GeomPointMake2dLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: GEOM_POINT_MAKE2D */ + case AntlrSQLParser::GEOM_POINT_MAKE3DZ: { + PRECONDITION(ctx->functionParam().size() == 4, + "GeomPointMake3dz requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(GeomPointMake3dzLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: GEOM_POINT_MAKE3DZ */ + case AntlrSQLParser::GEOG_POINT_MAKE2D: { + PRECONDITION(ctx->functionParam().size() == 3, + "GeogPointMake2d requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(GeogPointMake2dLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: GEOG_POINT_MAKE2D */ + case AntlrSQLParser::GEOG_POINT_MAKE3DZ: { + PRECONDITION(ctx->functionParam().size() == 4, + "GeogPointMake3dz requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(GeogPointMake3dzLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: GEOG_POINT_MAKE3DZ */ + case AntlrSQLParser::GEOM_TO_GEOG: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeomToGeog requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeomToGeogLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOM_TO_GEOG */ + case AntlrSQLParser::GEOG_TO_GEOM: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeogToGeom requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeogToGeomLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOG_TO_GEOM */ + case AntlrSQLParser::GEOG_CENTROID: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeogCentroid requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeogCentroidLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOG_CENTROID */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 44d61a57ee42ade35cb311c4a7fa8e000b799d70 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 23:55:45 +0200 Subject: [PATCH 81/86] feat(meos): add index-based geometry extraction and collection intersection NES operators (W133) Wires GEO_GEO_N (wkt,n:U64->VARCHAR) for nth component of a geometry collection, LINE_POINT_N (wkt,n:U64->VARCHAR) for nth point of a linestring (1-based), and GEOM_INTERSECTION2D_COLL (wkt1,wkt2->VARCHAR) for collection-typed intersection. All ops parse WKT via geom_in and serialize results with geo_as_text. --- .../Functions/Meos/GeoGeoNLogicalFunction.hpp | 48 +++++++++ .../GeomIntersection2dCollLogicalFunction.hpp | 48 +++++++++ .../Meos/LinePointNLogicalFunction.hpp | 48 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../Functions/Meos/GeoGeoNLogicalFunction.cpp | 99 +++++++++++++++++++ .../GeomIntersection2dCollLogicalFunction.cpp | 99 +++++++++++++++++++ .../Meos/LinePointNLogicalFunction.cpp | 99 +++++++++++++++++++ .../Meos/GeoGeoNPhysicalFunction.hpp | 32 ++++++ ...GeomIntersection2dCollPhysicalFunction.hpp | 32 ++++++ .../Meos/LinePointNPhysicalFunction.hpp | 32 ++++++ .../src/Functions/Meos/CMakeLists.txt | 3 + .../Meos/GeoGeoNPhysicalFunction.cpp | 87 ++++++++++++++++ ...GeomIntersection2dCollPhysicalFunction.cpp | 89 +++++++++++++++++ .../Meos/LinePointNPhysicalFunction.cpp | 87 ++++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 5 +- .../src/AntlrSQLQueryPlanCreator.cpp | 30 ++++++ 16 files changed, 840 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeoGeoNLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomIntersection2dCollLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/LinePointNLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoGeoNLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomIntersection2dCollLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/LinePointNLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoGeoNPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomIntersection2dCollPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/LinePointNPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoGeoNPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomIntersection2dCollPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/LinePointNPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeoGeoNLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoGeoNLogicalFunction.hpp new file mode 100644 index 0000000000..aba38ae724 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoGeoNLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nth component geometry from a geometry collection as WKT. + */ +class GeoGeoNLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoGeoN"; + + GeoGeoNLogicalFunction(LogicalFunction wkt, LogicalFunction n); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomIntersection2dCollLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomIntersection2dCollLogicalFunction.hpp new file mode 100644 index 0000000000..e7dfc55e8a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomIntersection2dCollLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the collection-typed 2D intersection of two geometries as WKT. + */ +class GeomIntersection2dCollLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomIntersection2dColl"; + + GeomIntersection2dCollLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/LinePointNLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/LinePointNLogicalFunction.hpp new file mode 100644 index 0000000000..0213b796b2 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/LinePointNLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the nth point of a linestring as WKT (1-based index). + */ +class LinePointNLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "LinePointN"; + + LinePointNLogicalFunction(LogicalFunction wkt, LogicalFunction n); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 505a3df92b..c3fd3c8c04 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -466,6 +466,9 @@ add_plugin(GeogPointMake3dz LogicalFunction nes-logical-operators GeogPointMake3 add_plugin(GeomToGeog LogicalFunction nes-logical-operators GeomToGeogLogicalFunction.cpp) add_plugin(GeogToGeom LogicalFunction nes-logical-operators GeogToGeomLogicalFunction.cpp) add_plugin(GeogCentroid LogicalFunction nes-logical-operators GeogCentroidLogicalFunction.cpp) +add_plugin(GeoGeoN LogicalFunction nes-logical-operators GeoGeoNLogicalFunction.cpp) +add_plugin(LinePointN LogicalFunction nes-logical-operators LinePointNLogicalFunction.cpp) +add_plugin(GeomIntersection2dColl LogicalFunction nes-logical-operators GeomIntersection2dCollLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeoGeoNLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoGeoNLogicalFunction.cpp new file mode 100644 index 0000000000..e897eab065 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoGeoNLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoGeoNLogicalFunction::GeoGeoNLogicalFunction(LogicalFunction wkt, LogicalFunction n) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(n)); +} + +DataType GeoGeoNLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoGeoNLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoGeoNLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoGeoNLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeoGeoNLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoGeoNLogicalFunction::getType() const { return NAME; } + +bool GeoGeoNLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoGeoNLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoGeoNLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "n must be UINT64"); + return withChildren(c); +} + +SerializableFunction GeoGeoNLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoGeoNLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeoGeoNLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeoGeoNLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomIntersection2dCollLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomIntersection2dCollLogicalFunction.cpp new file mode 100644 index 0000000000..89ec07c54c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomIntersection2dCollLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomIntersection2dCollLogicalFunction::GeomIntersection2dCollLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); +} + +DataType GeomIntersection2dCollLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomIntersection2dCollLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomIntersection2dCollLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomIntersection2dCollLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeomIntersection2dCollLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomIntersection2dCollLogicalFunction::getType() const { return NAME; } + +bool GeomIntersection2dCollLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomIntersection2dCollLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomIntersection2dCollLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomIntersection2dCollLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomIntersection2dCollLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeomIntersection2dCollLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeomIntersection2dCollLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/LinePointNLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/LinePointNLogicalFunction.cpp new file mode 100644 index 0000000000..b91adbe8e7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/LinePointNLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +LinePointNLogicalFunction::LinePointNLogicalFunction(LogicalFunction wkt, LogicalFunction n) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(n)); +} + +DataType LinePointNLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction LinePointNLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector LinePointNLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction LinePointNLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "LinePointNLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view LinePointNLogicalFunction::getType() const { return NAME; } + +bool LinePointNLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string LinePointNLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction LinePointNLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "n must be UINT64"); + return withChildren(c); +} + +SerializableFunction LinePointNLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterLinePointNLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "LinePointNLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return LinePointNLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoGeoNPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoGeoNPhysicalFunction.hpp new file mode 100644 index 0000000000..8e6b2244d6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoGeoNPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoGeoNPhysicalFunction : public PhysicalFunctionConcept { +public: + GeoGeoNPhysicalFunction(PhysicalFunction wkt, PhysicalFunction n); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomIntersection2dCollPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomIntersection2dCollPhysicalFunction.hpp new file mode 100644 index 0000000000..f9377c5aa3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomIntersection2dCollPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomIntersection2dCollPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomIntersection2dCollPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/LinePointNPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/LinePointNPhysicalFunction.hpp new file mode 100644 index 0000000000..71d4238170 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/LinePointNPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class LinePointNPhysicalFunction : public PhysicalFunctionConcept { +public: + LinePointNPhysicalFunction(PhysicalFunction wkt, PhysicalFunction n); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 254b925187..630fabdc71 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -465,6 +465,9 @@ add_plugin(GeogPointMake3dz PhysicalFunction nes-physical-operators GeogPointMak add_plugin(GeomToGeog PhysicalFunction nes-physical-operators GeomToGeogPhysicalFunction.cpp) add_plugin(GeogToGeom PhysicalFunction nes-physical-operators GeogToGeomPhysicalFunction.cpp) add_plugin(GeogCentroid PhysicalFunction nes-physical-operators GeogCentroidPhysicalFunction.cpp) +add_plugin(GeoGeoN PhysicalFunction nes-physical-operators GeoGeoNPhysicalFunction.cpp) +add_plugin(LinePointN PhysicalFunction nes-physical-operators LinePointNPhysicalFunction.cpp) +add_plugin(GeomIntersection2dColl PhysicalFunction nes-physical-operators GeomIntersection2dCollPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/GeoGeoNPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoGeoNPhysicalFunction.cpp new file mode 100644 index 0000000000..eb66754dd6 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoGeoNPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoGeoNPhysicalFunction::GeoGeoNPhysicalFunction(PhysicalFunction wkt, PhysicalFunction n) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(n)); +} + +VarVal GeoGeoNPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto n = paramFns[1].execute(record, arena).cast>(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, uint64_t n, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geo_geo_n(gs, (int)n); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, n, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoGeoNPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeoGeoNPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeoGeoNPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomIntersection2dCollPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomIntersection2dCollPhysicalFunction.cpp new file mode 100644 index 0000000000..29f1e7d7f2 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomIntersection2dCollPhysicalFunction.cpp @@ -0,0 +1,89 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomIntersection2dCollPhysicalFunction::GeomIntersection2dCollPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); +} + +VarVal GeomIntersection2dCollPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0u; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0u; } + GSERIALIZED* result = geom_intersection2d_coll(gs1, gs2); + free(gs1); free(gs2); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt1, wkt2, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomIntersection2dCollPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeomIntersection2dCollPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeomIntersection2dCollPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/LinePointNPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/LinePointNPhysicalFunction.cpp new file mode 100644 index 0000000000..4edece9170 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/LinePointNPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +LinePointNPhysicalFunction::LinePointNPhysicalFunction(PhysicalFunction wkt, PhysicalFunction n) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(n)); +} + +VarVal LinePointNPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto n = paramFns[1].execute(record, arena).cast>(); + constexpr uint32_t MAX_LEN = 8192; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, uint64_t n, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = line_point_n(gs, (int)n); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, n, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterLinePointNPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "LinePointNPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return LinePointNPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 72fdf8a158..d795d54ab9 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_POINT_MAKE2D | GEOM_POINT_MAKE3DZ | GEOG_POINT_MAKE2D | GEOG_POINT_MAKE3DZ | GEOM_TO_GEOG | GEOG_TO_GEOM | GEOG_CENTROID | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_POINT_MAKE2D | GEOM_POINT_MAKE3DZ | GEOG_POINT_MAKE2D | GEOG_POINT_MAKE3DZ | GEOM_TO_GEOG | GEOG_TO_GEOM | GEOG_CENTROID | GEO_GEO_N | LINE_POINT_N | GEOM_INTERSECTION2D_COLL | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -936,6 +936,9 @@ GEOG_POINT_MAKE3DZ: 'GEOG_POINT_MAKE3DZ' | 'geogpoint_make3dz'; GEOM_TO_GEOG: 'GEOM_TO_GEOG' | 'geom_to_geog'; GEOG_TO_GEOM: 'GEOG_TO_GEOM' | 'geog_to_geom'; GEOG_CENTROID: 'GEOG_CENTROID' | 'geog_centroid'; +GEO_GEO_N: 'GEO_GEO_N' | 'geo_geo_n'; +LINE_POINT_N: 'LINE_POINT_N' | 'line_point_n'; +GEOM_INTERSECTION2D_COLL: 'GEOM_INTERSECTION2D_COLL' | 'geom_intersection2d_coll'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index bde0966bf6..9ffd21c82b 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -517,6 +517,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -11008,6 +11011,33 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(GeogCentroidLogicalFunction(std::move(arg0), std::move(arg1))); } /* END CODEGEN PARSER GLUE: GEOG_CENTROID */ + case AntlrSQLParser::GEO_GEO_N: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeoGeoN requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeoGeoNLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEO_GEO_N */ + case AntlrSQLParser::LINE_POINT_N: { + PRECONDITION(ctx->functionParam().size() == 2, + "LinePointN requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(LinePointNLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: LINE_POINT_N */ + case AntlrSQLParser::GEOM_INTERSECTION2D_COLL: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeomIntersection2dColl requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeomIntersection2dCollLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEOM_INTERSECTION2D_COLL */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 5781c428288bd1d81f425d772e74cd5c217591db Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Mon, 15 Jun 2026 23:55:55 +0200 Subject: [PATCH 82/86] feat(meos): add geometry format, pipeline, and bounding-radius NES operators (W134) Wires GEO_AS_GEOJSON/HEXEWKB/EWKT (wkt->VARCHAR), GEO_FROM_GEOJSON and GEOM_FROM_HEXEWKB (string->WKT), GEO_TRANSFORM_PIPELINE (wkt,pipeline,srid,dir-> VARCHAR), GEOM_MIN_BOUNDING_CENTER (wkt->VARCHAR center WKT), and GEOM_MIN_BOUNDING_RADIUS (wkt->FLOAT64). GeoJSON buffer is MAX_LEN=16384 to accommodate larger JSON payloads. --- .../Meos/GeoAsEwktLogicalFunction.hpp | 48 ++++++++ .../Meos/GeoAsGeojsonLogicalFunction.hpp | 48 ++++++++ .../Meos/GeoAsHexewkbLogicalFunction.hpp | 48 ++++++++ .../Meos/GeoFromGeojsonLogicalFunction.hpp | 48 ++++++++ .../GeoTransformPipelineLogicalFunction.hpp | 48 ++++++++ .../Meos/GeomFromHexewkbLogicalFunction.hpp | 48 ++++++++ .../GeomMinBoundingCenterLogicalFunction.hpp | 48 ++++++++ .../GeomMinBoundingRadiusLogicalFunction.hpp | 48 ++++++++ .../src/Functions/Meos/CMakeLists.txt | 8 ++ .../Meos/GeoAsEwktLogicalFunction.cpp | 99 +++++++++++++++++ .../Meos/GeoAsGeojsonLogicalFunction.cpp | 102 +++++++++++++++++ .../Meos/GeoAsHexewkbLogicalFunction.cpp | 99 +++++++++++++++++ .../Meos/GeoFromGeojsonLogicalFunction.cpp | 96 ++++++++++++++++ .../GeoTransformPipelineLogicalFunction.cpp | 105 ++++++++++++++++++ .../Meos/GeomFromHexewkbLogicalFunction.cpp | 96 ++++++++++++++++ .../GeomMinBoundingCenterLogicalFunction.cpp | 96 ++++++++++++++++ .../GeomMinBoundingRadiusLogicalFunction.cpp | 96 ++++++++++++++++ .../Meos/GeoAsEwktPhysicalFunction.hpp | 32 ++++++ .../Meos/GeoAsGeojsonPhysicalFunction.hpp | 32 ++++++ .../Meos/GeoAsHexewkbPhysicalFunction.hpp | 32 ++++++ .../Meos/GeoFromGeojsonPhysicalFunction.hpp | 32 ++++++ .../GeoTransformPipelinePhysicalFunction.hpp | 32 ++++++ .../Meos/GeomFromHexewkbPhysicalFunction.hpp | 32 ++++++ .../GeomMinBoundingCenterPhysicalFunction.hpp | 32 ++++++ .../GeomMinBoundingRadiusPhysicalFunction.hpp | 32 ++++++ .../src/Functions/Meos/CMakeLists.txt | 8 ++ .../Meos/GeoAsEwktPhysicalFunction.cpp | 84 ++++++++++++++ .../Meos/GeoAsGeojsonPhysicalFunction.cpp | 87 +++++++++++++++ .../Meos/GeoAsHexewkbPhysicalFunction.cpp | 84 ++++++++++++++ .../Meos/GeoFromGeojsonPhysicalFunction.cpp | 81 ++++++++++++++ .../GeoTransformPipelinePhysicalFunction.cpp | 93 ++++++++++++++++ .../Meos/GeomFromHexewkbPhysicalFunction.cpp | 81 ++++++++++++++ .../GeomMinBoundingCenterPhysicalFunction.cpp | 85 ++++++++++++++ .../GeomMinBoundingRadiusPhysicalFunction.cpp | 72 ++++++++++++ .../Meos/LineLocatePointPhysicalFunction.cpp | 2 +- .../Meos/LineNumpointsPhysicalFunction.cpp | 2 +- nes-sql-parser/AntlrSQL.g4 | 10 +- .../src/AntlrSQLQueryPlanCreator.cpp | 79 +++++++++++++ 38 files changed, 2202 insertions(+), 3 deletions(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeoAsEwktLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeoAsGeojsonLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeoAsHexewkbLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeoFromGeojsonLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeoTransformPipelineLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomFromHexewkbLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomMinBoundingCenterLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/GeomMinBoundingRadiusLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoAsEwktLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoAsGeojsonLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoAsHexewkbLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoFromGeojsonLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeoTransformPipelineLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomFromHexewkbLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomMinBoundingCenterLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomMinBoundingRadiusLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoAsEwktPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoAsGeojsonPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoAsHexewkbPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoFromGeojsonPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeoTransformPipelinePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomFromHexewkbPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomMinBoundingCenterPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomMinBoundingRadiusPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoAsEwktPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoAsGeojsonPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoAsHexewkbPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoFromGeojsonPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeoTransformPipelinePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomFromHexewkbPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomMinBoundingCenterPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomMinBoundingRadiusPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeoAsEwktLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoAsEwktLogicalFunction.hpp new file mode 100644 index 0000000000..c0eeca384e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoAsEwktLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Serializes a geometry to EWKT with the given coordinate precision. + */ +class GeoAsEwktLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoAsEwkt"; + + GeoAsEwktLogicalFunction(LogicalFunction wkt, LogicalFunction precision); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeoAsGeojsonLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoAsGeojsonLogicalFunction.hpp new file mode 100644 index 0000000000..c0bd991cf0 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoAsGeojsonLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Serializes a geometry to a GeoJSON string with given option and precision. + */ +class GeoAsGeojsonLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoAsGeojson"; + + GeoAsGeojsonLogicalFunction(LogicalFunction wkt, LogicalFunction option, LogicalFunction precision); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeoAsHexewkbLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoAsHexewkbLogicalFunction.hpp new file mode 100644 index 0000000000..471470c0dd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoAsHexewkbLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Serializes a geometry to hex EWKB with the given endian ('NDR' or 'XDR'). + */ +class GeoAsHexewkbLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoAsHexewkb"; + + GeoAsHexewkbLogicalFunction(LogicalFunction wkt, LogicalFunction endian); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeoFromGeojsonLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoFromGeojsonLogicalFunction.hpp new file mode 100644 index 0000000000..2654c72b5a --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoFromGeojsonLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Parses a GeoJSON string and returns the geometry as WKT. + */ +class GeoFromGeojsonLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoFromGeojson"; + + GeoFromGeojsonLogicalFunction(LogicalFunction json); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeoTransformPipelineLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeoTransformPipelineLogicalFunction.hpp new file mode 100644 index 0000000000..1f52566b0e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeoTransformPipelineLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Reprojects a geometry using a PROJ pipeline string and target SRID, as WKT. + */ +class GeoTransformPipelineLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeoTransformPipeline"; + + GeoTransformPipelineLogicalFunction(LogicalFunction wkt, LogicalFunction pipeline, LogicalFunction srid_to, LogicalFunction is_forward); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomFromHexewkbLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomFromHexewkbLogicalFunction.hpp new file mode 100644 index 0000000000..b0e273e80d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomFromHexewkbLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Parses a hex EWKB string and returns the geometry as WKT. + */ +class GeomFromHexewkbLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomFromHexewkb"; + + GeomFromHexewkbLogicalFunction(LogicalFunction hex); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomMinBoundingCenterLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomMinBoundingCenterLogicalFunction.hpp new file mode 100644 index 0000000000..049d7b7795 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomMinBoundingCenterLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the center point of the minimum bounding circle of a geometry as WKT. + */ +class GeomMinBoundingCenterLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomMinBoundingCenter"; + + GeomMinBoundingCenterLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/GeomMinBoundingRadiusLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomMinBoundingRadiusLogicalFunction.hpp new file mode 100644 index 0000000000..9e4b182013 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomMinBoundingRadiusLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns the radius of the minimum bounding circle of a geometry. + */ +class GeomMinBoundingRadiusLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomMinBoundingRadius"; + + GeomMinBoundingRadiusLogicalFunction(LogicalFunction wkt); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index c3fd3c8c04..0c6e53dade 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -469,6 +469,14 @@ add_plugin(GeogCentroid LogicalFunction nes-logical-operators GeogCentroidLogica add_plugin(GeoGeoN LogicalFunction nes-logical-operators GeoGeoNLogicalFunction.cpp) add_plugin(LinePointN LogicalFunction nes-logical-operators LinePointNLogicalFunction.cpp) add_plugin(GeomIntersection2dColl LogicalFunction nes-logical-operators GeomIntersection2dCollLogicalFunction.cpp) +add_plugin(GeoAsGeojson LogicalFunction nes-logical-operators GeoAsGeojsonLogicalFunction.cpp) +add_plugin(GeoAsHexewkb LogicalFunction nes-logical-operators GeoAsHexewkbLogicalFunction.cpp) +add_plugin(GeoAsEwkt LogicalFunction nes-logical-operators GeoAsEwktLogicalFunction.cpp) +add_plugin(GeoFromGeojson LogicalFunction nes-logical-operators GeoFromGeojsonLogicalFunction.cpp) +add_plugin(GeomFromHexewkb LogicalFunction nes-logical-operators GeomFromHexewkbLogicalFunction.cpp) +add_plugin(GeoTransformPipeline LogicalFunction nes-logical-operators GeoTransformPipelineLogicalFunction.cpp) +add_plugin(GeomMinBoundingCenter LogicalFunction nes-logical-operators GeomMinBoundingCenterLogicalFunction.cpp) +add_plugin(GeomMinBoundingRadius LogicalFunction nes-logical-operators GeomMinBoundingRadiusLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeoAsEwktLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoAsEwktLogicalFunction.cpp new file mode 100644 index 0000000000..7b45560683 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoAsEwktLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoAsEwktLogicalFunction::GeoAsEwktLogicalFunction(LogicalFunction wkt, LogicalFunction precision) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(precision)); +} + +DataType GeoAsEwktLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoAsEwktLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoAsEwktLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoAsEwktLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeoAsEwktLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoAsEwktLogicalFunction::getType() const { return NAME; } + +bool GeoAsEwktLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoAsEwktLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoAsEwktLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "precision must be UINT64"); + return withChildren(c); +} + +SerializableFunction GeoAsEwktLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoAsEwktLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeoAsEwktLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeoAsEwktLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeoAsGeojsonLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoAsGeojsonLogicalFunction.cpp new file mode 100644 index 0000000000..b0f1ed3ba6 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoAsGeojsonLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoAsGeojsonLogicalFunction::GeoAsGeojsonLogicalFunction(LogicalFunction wkt, LogicalFunction option, LogicalFunction precision) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(3); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(option)); + parameters.push_back(std::move(precision)); +} + +DataType GeoAsGeojsonLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoAsGeojsonLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoAsGeojsonLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoAsGeojsonLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "GeoAsGeojsonLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoAsGeojsonLogicalFunction::getType() const { return NAME; } + +bool GeoAsGeojsonLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoAsGeojsonLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoAsGeojsonLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "option must be UINT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "precision must be UINT64"); + return withChildren(c); +} + +SerializableFunction GeoAsGeojsonLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoAsGeojsonLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "GeoAsGeojsonLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return GeoAsGeojsonLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeoAsHexewkbLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoAsHexewkbLogicalFunction.cpp new file mode 100644 index 0000000000..596880efcd --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoAsHexewkbLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoAsHexewkbLogicalFunction::GeoAsHexewkbLogicalFunction(LogicalFunction wkt, LogicalFunction endian) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(2); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(endian)); +} + +DataType GeoAsHexewkbLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoAsHexewkbLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoAsHexewkbLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoAsHexewkbLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "GeoAsHexewkbLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoAsHexewkbLogicalFunction::getType() const { return NAME; } + +bool GeoAsHexewkbLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoAsHexewkbLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoAsHexewkbLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "endian must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeoAsHexewkbLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoAsHexewkbLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "GeoAsHexewkbLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return GeoAsHexewkbLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeoFromGeojsonLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoFromGeojsonLogicalFunction.cpp new file mode 100644 index 0000000000..28076fcd7a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoFromGeojsonLogicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoFromGeojsonLogicalFunction::GeoFromGeojsonLogicalFunction(LogicalFunction json) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(1); + parameters.push_back(std::move(json)); +} + +DataType GeoFromGeojsonLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoFromGeojsonLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoFromGeojsonLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoFromGeojsonLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeoFromGeojsonLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoFromGeojsonLogicalFunction::getType() const { return NAME; } + +bool GeoFromGeojsonLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoFromGeojsonLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoFromGeojsonLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "json must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeoFromGeojsonLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoFromGeojsonLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeoFromGeojsonLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return GeoFromGeojsonLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeoTransformPipelineLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeoTransformPipelineLogicalFunction.cpp new file mode 100644 index 0000000000..0c67a248f1 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeoTransformPipelineLogicalFunction.cpp @@ -0,0 +1,105 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeoTransformPipelineLogicalFunction::GeoTransformPipelineLogicalFunction(LogicalFunction wkt, LogicalFunction pipeline, LogicalFunction srid_to, LogicalFunction is_forward) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(4); + parameters.push_back(std::move(wkt)); + parameters.push_back(std::move(pipeline)); + parameters.push_back(std::move(srid_to)); + parameters.push_back(std::move(is_forward)); +} + +DataType GeoTransformPipelineLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeoTransformPipelineLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeoTransformPipelineLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeoTransformPipelineLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 4, + "GeoTransformPipelineLogicalFunction requires 4 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeoTransformPipelineLogicalFunction::getType() const { return NAME; } + +bool GeoTransformPipelineLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeoTransformPipelineLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeoTransformPipelineLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(4); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "pipeline must be VARSIZED"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "srid_to must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::UINT64), "is_forward must be UINT64"); + return withChildren(c); +} + +SerializableFunction GeoTransformPipelineLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeoTransformPipelineLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 4, + "GeoTransformPipelineLogicalFunction requires 4 children but got {}", + arguments.children.size()); + return GeoTransformPipelineLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomFromHexewkbLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomFromHexewkbLogicalFunction.cpp new file mode 100644 index 0000000000..3bb0638e11 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomFromHexewkbLogicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomFromHexewkbLogicalFunction::GeomFromHexewkbLogicalFunction(LogicalFunction hex) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(1); + parameters.push_back(std::move(hex)); +} + +DataType GeomFromHexewkbLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomFromHexewkbLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomFromHexewkbLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomFromHexewkbLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeomFromHexewkbLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomFromHexewkbLogicalFunction::getType() const { return NAME; } + +bool GeomFromHexewkbLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomFromHexewkbLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomFromHexewkbLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "hex must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomFromHexewkbLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomFromHexewkbLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeomFromHexewkbLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return GeomFromHexewkbLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomMinBoundingCenterLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomMinBoundingCenterLogicalFunction.cpp new file mode 100644 index 0000000000..3fda8dff38 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomMinBoundingCenterLogicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomMinBoundingCenterLogicalFunction::GeomMinBoundingCenterLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::VARSIZED)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeomMinBoundingCenterLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomMinBoundingCenterLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomMinBoundingCenterLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomMinBoundingCenterLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeomMinBoundingCenterLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomMinBoundingCenterLogicalFunction::getType() const { return NAME; } + +bool GeomMinBoundingCenterLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomMinBoundingCenterLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomMinBoundingCenterLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomMinBoundingCenterLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomMinBoundingCenterLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeomMinBoundingCenterLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return GeomMinBoundingCenterLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/GeomMinBoundingRadiusLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomMinBoundingRadiusLogicalFunction.cpp new file mode 100644 index 0000000000..e7603f2c0c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomMinBoundingRadiusLogicalFunction.cpp @@ -0,0 +1,96 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomMinBoundingRadiusLogicalFunction::GeomMinBoundingRadiusLogicalFunction(LogicalFunction wkt) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(1); + parameters.push_back(std::move(wkt)); +} + +DataType GeomMinBoundingRadiusLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomMinBoundingRadiusLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomMinBoundingRadiusLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomMinBoundingRadiusLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 1, + "GeomMinBoundingRadiusLogicalFunction requires 1 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomMinBoundingRadiusLogicalFunction::getType() const { return NAME; } + +bool GeomMinBoundingRadiusLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomMinBoundingRadiusLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomMinBoundingRadiusLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(1); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomMinBoundingRadiusLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomMinBoundingRadiusLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 1, + "GeomMinBoundingRadiusLogicalFunction requires 1 children but got {}", + arguments.children.size()); + return GeomMinBoundingRadiusLogicalFunction( + std::move(arguments.children[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoAsEwktPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoAsEwktPhysicalFunction.hpp new file mode 100644 index 0000000000..b400321472 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoAsEwktPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoAsEwktPhysicalFunction : public PhysicalFunctionConcept { +public: + GeoAsEwktPhysicalFunction(PhysicalFunction wkt, PhysicalFunction precision); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoAsGeojsonPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoAsGeojsonPhysicalFunction.hpp new file mode 100644 index 0000000000..e8ad9401a5 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoAsGeojsonPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoAsGeojsonPhysicalFunction : public PhysicalFunctionConcept { +public: + GeoAsGeojsonPhysicalFunction(PhysicalFunction wkt, PhysicalFunction option, PhysicalFunction precision); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoAsHexewkbPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoAsHexewkbPhysicalFunction.hpp new file mode 100644 index 0000000000..fedc44feeb --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoAsHexewkbPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoAsHexewkbPhysicalFunction : public PhysicalFunctionConcept { +public: + GeoAsHexewkbPhysicalFunction(PhysicalFunction wkt, PhysicalFunction endian); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoFromGeojsonPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoFromGeojsonPhysicalFunction.hpp new file mode 100644 index 0000000000..3097db9f89 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoFromGeojsonPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoFromGeojsonPhysicalFunction : public PhysicalFunctionConcept { +public: + GeoFromGeojsonPhysicalFunction(PhysicalFunction json); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeoTransformPipelinePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeoTransformPipelinePhysicalFunction.hpp new file mode 100644 index 0000000000..969e3b3533 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeoTransformPipelinePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeoTransformPipelinePhysicalFunction : public PhysicalFunctionConcept { +public: + GeoTransformPipelinePhysicalFunction(PhysicalFunction wkt, PhysicalFunction pipeline, PhysicalFunction srid_to, PhysicalFunction is_forward); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomFromHexewkbPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomFromHexewkbPhysicalFunction.hpp new file mode 100644 index 0000000000..323d35e263 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomFromHexewkbPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomFromHexewkbPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomFromHexewkbPhysicalFunction(PhysicalFunction hex); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomMinBoundingCenterPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomMinBoundingCenterPhysicalFunction.hpp new file mode 100644 index 0000000000..c0440f0a7e --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomMinBoundingCenterPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomMinBoundingCenterPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomMinBoundingCenterPhysicalFunction(PhysicalFunction wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomMinBoundingRadiusPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomMinBoundingRadiusPhysicalFunction.hpp new file mode 100644 index 0000000000..79e140cd92 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomMinBoundingRadiusPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomMinBoundingRadiusPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomMinBoundingRadiusPhysicalFunction(PhysicalFunction wkt); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 630fabdc71..efab7778ab 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -468,6 +468,14 @@ add_plugin(GeogCentroid PhysicalFunction nes-physical-operators GeogCentroidPhys add_plugin(GeoGeoN PhysicalFunction nes-physical-operators GeoGeoNPhysicalFunction.cpp) add_plugin(LinePointN PhysicalFunction nes-physical-operators LinePointNPhysicalFunction.cpp) add_plugin(GeomIntersection2dColl PhysicalFunction nes-physical-operators GeomIntersection2dCollPhysicalFunction.cpp) +add_plugin(GeoAsGeojson PhysicalFunction nes-physical-operators GeoAsGeojsonPhysicalFunction.cpp) +add_plugin(GeoAsHexewkb PhysicalFunction nes-physical-operators GeoAsHexewkbPhysicalFunction.cpp) +add_plugin(GeoAsEwkt PhysicalFunction nes-physical-operators GeoAsEwktPhysicalFunction.cpp) +add_plugin(GeoFromGeojson PhysicalFunction nes-physical-operators GeoFromGeojsonPhysicalFunction.cpp) +add_plugin(GeomFromHexewkb PhysicalFunction nes-physical-operators GeomFromHexewkbPhysicalFunction.cpp) +add_plugin(GeoTransformPipeline PhysicalFunction nes-physical-operators GeoTransformPipelinePhysicalFunction.cpp) +add_plugin(GeomMinBoundingCenter PhysicalFunction nes-physical-operators GeomMinBoundingCenterPhysicalFunction.cpp) +add_plugin(GeomMinBoundingRadius PhysicalFunction nes-physical-operators GeomMinBoundingRadiusPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/GeoAsEwktPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoAsEwktPhysicalFunction.cpp new file mode 100644 index 0000000000..723f76d418 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoAsEwktPhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoAsEwktPhysicalFunction::GeoAsEwktPhysicalFunction(PhysicalFunction wkt, PhysicalFunction precision) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(precision)); +} + +VarVal GeoAsEwktPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto precision = paramFns[1].execute(record, arena).cast>(); + constexpr uint32_t MAX_LEN = 16384; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, uint64_t precision, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + char* out = geo_as_ewkt(gs, (int)precision); + free(gs); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, precision, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoAsEwktPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeoAsEwktPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeoAsEwktPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeoAsGeojsonPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoAsGeojsonPhysicalFunction.cpp new file mode 100644 index 0000000000..4cc0e6ed08 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoAsGeojsonPhysicalFunction.cpp @@ -0,0 +1,87 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoAsGeojsonPhysicalFunction::GeoAsGeojsonPhysicalFunction(PhysicalFunction wkt, PhysicalFunction option, PhysicalFunction precision) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(option)); + paramFns.push_back(std::move(precision)); +} + +VarVal GeoAsGeojsonPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto option = paramFns[1].execute(record, arena).cast>(); + auto precision = paramFns[2].execute(record, arena).cast>(); + constexpr uint32_t MAX_LEN = 16384; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, uint64_t option, uint64_t precision, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + char* out = geo_as_geojson(gs, (int)option, (int)precision, nullptr); + free(gs); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, option, precision, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoAsGeojsonPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "GeoAsGeojsonPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return GeoAsGeojsonPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeoAsHexewkbPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoAsHexewkbPhysicalFunction.cpp new file mode 100644 index 0000000000..75ea7c67ad --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoAsHexewkbPhysicalFunction.cpp @@ -0,0 +1,84 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoAsHexewkbPhysicalFunction::GeoAsHexewkbPhysicalFunction(PhysicalFunction wkt, PhysicalFunction endian) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(endian)); +} + +VarVal GeoAsHexewkbPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto endian = paramFns[1].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 16384; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, const char* e, uint32_t esz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz), es(e, esz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + char* out = geo_as_hexewkb(gs, es.c_str()); + free(gs); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, endian, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoAsHexewkbPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "GeoAsHexewkbPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return GeoAsHexewkbPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeoFromGeojsonPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoFromGeojsonPhysicalFunction.cpp new file mode 100644 index 0000000000..ba739eda83 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoFromGeojsonPhysicalFunction.cpp @@ -0,0 +1,81 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoFromGeojsonPhysicalFunction::GeoFromGeojsonPhysicalFunction(PhysicalFunction json) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(json)); +} + +VarVal GeoFromGeojsonPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto json = paramFns[0].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 16384; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* j, uint32_t jsz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string js(j, jsz); + GSERIALIZED* result = geo_from_geojson(js.c_str()); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + json, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoFromGeojsonPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeoFromGeojsonPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return GeoFromGeojsonPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeoTransformPipelinePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeoTransformPipelinePhysicalFunction.cpp new file mode 100644 index 0000000000..a79ad8b00e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeoTransformPipelinePhysicalFunction.cpp @@ -0,0 +1,93 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeoTransformPipelinePhysicalFunction::GeoTransformPipelinePhysicalFunction(PhysicalFunction wkt, PhysicalFunction pipeline, PhysicalFunction srid_to, PhysicalFunction is_forward) +{ + paramFns.reserve(4); + paramFns.push_back(std::move(wkt)); + paramFns.push_back(std::move(pipeline)); + paramFns.push_back(std::move(srid_to)); + paramFns.push_back(std::move(is_forward)); +} + +VarVal GeoTransformPipelinePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + auto pipeline = paramFns[1].execute(record, arena).cast(); + auto srid_to = paramFns[2].execute(record, arena).cast>(); + auto is_forward = paramFns[3].execute(record, arena).cast>(); + constexpr uint32_t MAX_LEN = 16384; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, const char* p, uint32_t psz, uint64_t srid_to, uint64_t is_forward, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz), ps(p, psz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + GSERIALIZED* result = geo_transform_pipeline(gs, const_cast(ps.c_str()), (int32_t)srid_to, (bool)is_forward); + free(gs); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, pipeline, srid_to, is_forward, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeoTransformPipelinePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 4, + "GeoTransformPipelinePhysicalFunction requires 4 children but got {}", + arguments.childFunctions.size()); + return GeoTransformPipelinePhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomFromHexewkbPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomFromHexewkbPhysicalFunction.cpp new file mode 100644 index 0000000000..64de342519 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomFromHexewkbPhysicalFunction.cpp @@ -0,0 +1,81 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomFromHexewkbPhysicalFunction::GeomFromHexewkbPhysicalFunction(PhysicalFunction hex) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(hex)); +} + +VarVal GeomFromHexewkbPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto hex = paramFns[0].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 16384; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* h, uint32_t hsz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string hs(h, hsz); + GSERIALIZED* result = geom_from_hexewkb(hs.c_str()); + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + hex, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomFromHexewkbPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeomFromHexewkbPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return GeomFromHexewkbPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomMinBoundingCenterPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomMinBoundingCenterPhysicalFunction.cpp new file mode 100644 index 0000000000..45f05a0313 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomMinBoundingCenterPhysicalFunction.cpp @@ -0,0 +1,85 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomMinBoundingCenterPhysicalFunction::GeomMinBoundingCenterPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeomMinBoundingCenterPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + constexpr uint32_t MAX_LEN = 16384; + auto outBuf = arena.allocateVariableSizedData(nautilus::val(MAX_LEN)); + + const auto actualLen = nautilus::invoke( + +[](const char* w, uint32_t wsz, char* buf, uint32_t bufMax) -> uint32_t { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0u; + MinBoundingCircle mbc = geom_min_bounding_radius(gs); + free(gs); + GSERIALIZED* result = mbc.center; + if (!result) return 0u; + char* out = geo_as_text(result, -1); + free(result); + if (!out) return 0u; + uint32_t len = static_cast(strlen(out)); + if (len > bufMax) len = bufMax; + memcpy(buf, out, len); + free(out); + return len; + } catch (const std::exception&) { return 0u; } + }, + wkt, outBuf.getContent(), nautilus::val(MAX_LEN)); + + VarVal(actualLen).writeToMemory(outBuf.getReference()); + return outBuf; +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomMinBoundingCenterPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeomMinBoundingCenterPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return GeomMinBoundingCenterPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/GeomMinBoundingRadiusPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomMinBoundingRadiusPhysicalFunction.cpp new file mode 100644 index 0000000000..48e87d1fbb --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomMinBoundingRadiusPhysicalFunction.cpp @@ -0,0 +1,72 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomMinBoundingRadiusPhysicalFunction::GeomMinBoundingRadiusPhysicalFunction(PhysicalFunction wkt) +{ + paramFns.reserve(1); + paramFns.push_back(std::move(wkt)); +} + +VarVal GeomMinBoundingRadiusPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt = paramFns[0].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* w, uint32_t wsz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s(w, wsz); + GSERIALIZED* gs = geom_in(s.c_str(), -1); + if (!gs) return 0.0; + MinBoundingCircle mbc = geom_min_bounding_radius(gs); + free(gs); + if (mbc.center) free(mbc.center); + return mbc.radius; + } catch (const std::exception&) { return 0.0; } + }, + wkt); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomMinBoundingRadiusPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 1, + "GeomMinBoundingRadiusPhysicalFunction requires 1 children but got {}", + arguments.childFunctions.size()); + return GeomMinBoundingRadiusPhysicalFunction( + std::move(arguments.childFunctions[0])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/LineLocatePointPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/LineLocatePointPhysicalFunction.cpp index 22cb999698..0f0e12b8bb 100644 --- a/nes-physical-operators/src/Functions/Meos/LineLocatePointPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/LineLocatePointPhysicalFunction.cpp @@ -45,7 +45,7 @@ VarVal LineLocatePointPhysicalFunction::execute(const Record& record, ArenaRef& auto wkt1 = paramFns[0].execute(record, arena).cast(); auto wkt2 = paramFns[1].execute(record, arena).cast(); const auto result = nautilus::invoke( - +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double -> double { + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz) -> double { try { MEOS::Meos::ensureMeosInitialized(); std::string s1(w1, w1sz), s2(w2, w2sz); diff --git a/nes-physical-operators/src/Functions/Meos/LineNumpointsPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/LineNumpointsPhysicalFunction.cpp index 60c8c90294..97ca449b29 100644 --- a/nes-physical-operators/src/Functions/Meos/LineNumpointsPhysicalFunction.cpp +++ b/nes-physical-operators/src/Functions/Meos/LineNumpointsPhysicalFunction.cpp @@ -43,7 +43,7 @@ VarVal LineNumpointsPhysicalFunction::execute(const Record& record, ArenaRef& ar { auto wkt = paramFns[0].execute(record, arena).cast(); const auto result = nautilus::invoke( - +[](const char* w, uint32_t wsz) -> double -> double { + +[](const char* w, uint32_t wsz) -> double { try { MEOS::Meos::ensureMeosInitialized(); std::string s(w, wsz); diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index d795d54ab9..fea595b6ba 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_POINT_MAKE2D | GEOM_POINT_MAKE3DZ | GEOG_POINT_MAKE2D | GEOG_POINT_MAKE3DZ | GEOM_TO_GEOG | GEOG_TO_GEOM | GEOG_CENTROID | GEO_GEO_N | LINE_POINT_N | GEOM_INTERSECTION2D_COLL | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_POINT_MAKE2D | GEOM_POINT_MAKE3DZ | GEOG_POINT_MAKE2D | GEOG_POINT_MAKE3DZ | GEOM_TO_GEOG | GEOG_TO_GEOM | GEOG_CENTROID | GEO_GEO_N | LINE_POINT_N | GEOM_INTERSECTION2D_COLL | GEO_AS_GEOJSON | GEO_AS_HEXEWKB | GEO_AS_EWKT | GEO_FROM_GEOJSON | GEOM_FROM_HEXEWKB | GEO_TRANSFORM_PIPELINE | GEOM_MIN_BOUNDING_CENTER | GEOM_MIN_BOUNDING_RADIUS | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -939,6 +939,14 @@ GEOG_CENTROID: 'GEOG_CENTROID' | 'geog_centroid'; GEO_GEO_N: 'GEO_GEO_N' | 'geo_geo_n'; LINE_POINT_N: 'LINE_POINT_N' | 'line_point_n'; GEOM_INTERSECTION2D_COLL: 'GEOM_INTERSECTION2D_COLL' | 'geom_intersection2d_coll'; +GEO_AS_GEOJSON: 'GEO_AS_GEOJSON' | 'geo_as_geojson'; +GEO_AS_HEXEWKB: 'GEO_AS_HEXEWKB' | 'geo_as_hexewkb'; +GEO_AS_EWKT: 'GEO_AS_EWKT' | 'geo_as_ewkt'; +GEO_FROM_GEOJSON: 'GEO_FROM_GEOJSON' | 'geo_from_geojson'; +GEOM_FROM_HEXEWKB: 'GEOM_FROM_HEXEWKB' | 'geom_from_hexewkb'; +GEO_TRANSFORM_PIPELINE: 'GEO_TRANSFORM_PIPELINE' | 'geo_transform_pipeline'; +GEOM_MIN_BOUNDING_CENTER: 'GEOM_MIN_BOUNDING_CENTER' | 'geom_min_bounding_radius'; +GEOM_MIN_BOUNDING_RADIUS: 'GEOM_MIN_BOUNDING_RADIUS' | 'geom_min_bounding_radius'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 9ffd21c82b..62505d9aa6 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -520,6 +520,14 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -11038,6 +11046,77 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(GeomIntersection2dCollLogicalFunction(std::move(arg0), std::move(arg1))); } /* END CODEGEN PARSER GLUE: GEOM_INTERSECTION2D_COLL */ + case AntlrSQLParser::GEO_AS_GEOJSON: { + PRECONDITION(ctx->functionParam().size() == 3, + "GeoAsGeojson requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(GeoAsGeojsonLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: GEO_AS_GEOJSON */ + case AntlrSQLParser::GEO_AS_HEXEWKB: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeoAsHexewkb requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeoAsHexewkbLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEO_AS_HEXEWKB */ + case AntlrSQLParser::GEO_AS_EWKT: { + PRECONDITION(ctx->functionParam().size() == 2, + "GeoAsEwkt requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(GeoAsEwktLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: GEO_AS_EWKT */ + case AntlrSQLParser::GEO_FROM_GEOJSON: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeoFromGeojson requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeoFromGeojsonLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEO_FROM_GEOJSON */ + case AntlrSQLParser::GEOM_FROM_HEXEWKB: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeomFromHexewkb requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeomFromHexewkbLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOM_FROM_HEXEWKB */ + case AntlrSQLParser::GEO_TRANSFORM_PIPELINE: { + PRECONDITION(ctx->functionParam().size() == 4, + "GeoTransformPipeline requires 4 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + return LogicalFunction(GeoTransformPipelineLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3))); + } + /* END CODEGEN PARSER GLUE: GEO_TRANSFORM_PIPELINE */ + case AntlrSQLParser::GEOM_MIN_BOUNDING_CENTER: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeomMinBoundingCenter requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeomMinBoundingCenterLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOM_MIN_BOUNDING_CENTER */ + case AntlrSQLParser::GEOM_MIN_BOUNDING_RADIUS: { + PRECONDITION(ctx->functionParam().size() == 1, + "GeomMinBoundingRadius requires 1 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + return LogicalFunction(GeomMinBoundingRadiusLogicalFunction(std::move(arg0))); + } + /* END CODEGEN PARSER GLUE: GEOM_MIN_BOUNDING_RADIUS */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 7a8d747e58ad410d0225f23db419887cba42363a Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Tue, 16 Jun 2026 06:14:49 +0200 Subject: [PATCH 83/86] feat(meos): add GEOM_RELATE_PATTERN DE-9IM relation NES operator (W135) Wires GEOM_RELATE_PATTERN(wkt1, wkt2, pattern) as a FLOAT64-returning per-event operator (1.0=match, 0.0=no match) via geom_relate_pattern, completing the core static geometry surface in MobilityNebula. --- .../Meos/GeomRelatePatternLogicalFunction.hpp | 48 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 1 + .../Meos/GeomRelatePatternLogicalFunction.cpp | 102 ++++++++++++++++++ .../GeomRelatePatternPhysicalFunction.hpp | 32 ++++++ .../src/Functions/Meos/CMakeLists.txt | 1 + .../GeomRelatePatternPhysicalFunction.cpp | 79 ++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 3 +- .../src/AntlrSQLQueryPlanCreator.cpp | 11 ++ 8 files changed, 276 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/GeomRelatePatternLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/GeomRelatePatternLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/GeomRelatePatternPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/GeomRelatePatternPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/GeomRelatePatternLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/GeomRelatePatternLogicalFunction.hpp new file mode 100644 index 0000000000..3afcb1dfba --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/GeomRelatePatternLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether two geometries satisfy a DE-9IM relation pattern, returning 1.0 if true. + */ +class GeomRelatePatternLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "GeomRelatePattern"; + + GeomRelatePatternLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2, LogicalFunction pattern); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 0c6e53dade..588f0630dd 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -477,6 +477,7 @@ add_plugin(GeomFromHexewkb LogicalFunction nes-logical-operators GeomFromHexewkb add_plugin(GeoTransformPipeline LogicalFunction nes-logical-operators GeoTransformPipelineLogicalFunction.cpp) add_plugin(GeomMinBoundingCenter LogicalFunction nes-logical-operators GeomMinBoundingCenterLogicalFunction.cpp) add_plugin(GeomMinBoundingRadius LogicalFunction nes-logical-operators GeomMinBoundingRadiusLogicalFunction.cpp) +add_plugin(GeomRelatePattern LogicalFunction nes-logical-operators GeomRelatePatternLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) add_plugin(GeomContains LogicalFunction nes-logical-operators GeomContainsLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/GeomRelatePatternLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/GeomRelatePatternLogicalFunction.cpp new file mode 100644 index 0000000000..dc3a27a7e8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/GeomRelatePatternLogicalFunction.cpp @@ -0,0 +1,102 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +GeomRelatePatternLogicalFunction::GeomRelatePatternLogicalFunction(LogicalFunction wkt1, LogicalFunction wkt2, LogicalFunction pattern) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(3); + parameters.push_back(std::move(wkt1)); + parameters.push_back(std::move(wkt2)); + parameters.push_back(std::move(pattern)); +} + +DataType GeomRelatePatternLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction GeomRelatePatternLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector GeomRelatePatternLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction GeomRelatePatternLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 3, + "GeomRelatePatternLogicalFunction requires 3 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view GeomRelatePatternLogicalFunction::getType() const { return NAME; } + +bool GeomRelatePatternLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string GeomRelatePatternLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction GeomRelatePatternLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(3); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::VARSIZED), "wkt1 must be VARSIZED"); + INVARIANT(c[1].getDataType().isType(DataType::Type::VARSIZED), "wkt2 must be VARSIZED"); + INVARIANT(c[2].getDataType().isType(DataType::Type::VARSIZED), "pattern must be VARSIZED"); + return withChildren(c); +} + +SerializableFunction GeomRelatePatternLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterGeomRelatePatternLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 3, + "GeomRelatePatternLogicalFunction requires 3 children but got {}", + arguments.children.size()); + return GeomRelatePatternLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/GeomRelatePatternPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/GeomRelatePatternPhysicalFunction.hpp new file mode 100644 index 0000000000..30b22f25a2 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/GeomRelatePatternPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class GeomRelatePatternPhysicalFunction : public PhysicalFunctionConcept { +public: + GeomRelatePatternPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2, PhysicalFunction pattern); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index efab7778ab..9b98275811 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -476,6 +476,7 @@ add_plugin(GeomFromHexewkb PhysicalFunction nes-physical-operators GeomFromHexew add_plugin(GeoTransformPipeline PhysicalFunction nes-physical-operators GeoTransformPipelinePhysicalFunction.cpp) add_plugin(GeomMinBoundingCenter PhysicalFunction nes-physical-operators GeomMinBoundingCenterPhysicalFunction.cpp) add_plugin(GeomMinBoundingRadius PhysicalFunction nes-physical-operators GeomMinBoundingRadiusPhysicalFunction.cpp) +add_plugin(GeomRelatePattern PhysicalFunction nes-physical-operators GeomRelatePatternPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) add_plugin(GeomContains PhysicalFunction nes-physical-operators GeomContainsPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/GeomRelatePatternPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/GeomRelatePatternPhysicalFunction.cpp new file mode 100644 index 0000000000..0a78fe9028 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/GeomRelatePatternPhysicalFunction.cpp @@ -0,0 +1,79 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +GeomRelatePatternPhysicalFunction::GeomRelatePatternPhysicalFunction(PhysicalFunction wkt1, PhysicalFunction wkt2, PhysicalFunction pattern) +{ + paramFns.reserve(3); + paramFns.push_back(std::move(wkt1)); + paramFns.push_back(std::move(wkt2)); + paramFns.push_back(std::move(pattern)); +} + +VarVal GeomRelatePatternPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto wkt1 = paramFns[0].execute(record, arena).cast(); + auto wkt2 = paramFns[1].execute(record, arena).cast(); + auto pattern = paramFns[2].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](const char* w1, uint32_t w1sz, const char* w2, uint32_t w2sz, const char* p, uint32_t psz) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string s1(w1, w1sz), s2(w2, w2sz), sp(p, psz); + GSERIALIZED* gs1 = geom_in(s1.c_str(), -1); + if (!gs1) return 0.0; + GSERIALIZED* gs2 = geom_in(s2.c_str(), -1); + if (!gs2) { free(gs1); return 0.0; } + bool r = geom_relate_pattern(gs1, gs2, const_cast(sp.c_str())); + free(gs1); free(gs2); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + wkt1, wkt2, pattern); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterGeomRelatePatternPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 3, + "GeomRelatePatternPhysicalFunction requires 3 children but got {}", + arguments.childFunctions.size()); + return GeomRelatePatternPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index fea595b6ba..a85c3c142b 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_POINT_MAKE2D | GEOM_POINT_MAKE3DZ | GEOG_POINT_MAKE2D | GEOG_POINT_MAKE3DZ | GEOM_TO_GEOG | GEOG_TO_GEOM | GEOG_CENTROID | GEO_GEO_N | LINE_POINT_N | GEOM_INTERSECTION2D_COLL | GEO_AS_GEOJSON | GEO_AS_HEXEWKB | GEO_AS_EWKT | GEO_FROM_GEOJSON | GEOM_FROM_HEXEWKB | GEO_TRANSFORM_PIPELINE | GEOM_MIN_BOUNDING_CENTER | GEOM_MIN_BOUNDING_RADIUS | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_POINT_MAKE2D | GEOM_POINT_MAKE3DZ | GEOG_POINT_MAKE2D | GEOG_POINT_MAKE3DZ | GEOM_TO_GEOG | GEOG_TO_GEOM | GEOG_CENTROID | GEO_GEO_N | LINE_POINT_N | GEOM_INTERSECTION2D_COLL | GEO_AS_GEOJSON | GEO_AS_HEXEWKB | GEO_AS_EWKT | GEO_FROM_GEOJSON | GEOM_FROM_HEXEWKB | GEO_TRANSFORM_PIPELINE | GEOM_MIN_BOUNDING_CENTER | GEOM_MIN_BOUNDING_RADIUS | GEOM_RELATE_PATTERN | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -947,6 +947,7 @@ GEOM_FROM_HEXEWKB: 'GEOM_FROM_HEXEWKB' | 'geom_from_hexewkb'; GEO_TRANSFORM_PIPELINE: 'GEO_TRANSFORM_PIPELINE' | 'geo_transform_pipeline'; GEOM_MIN_BOUNDING_CENTER: 'GEOM_MIN_BOUNDING_CENTER' | 'geom_min_bounding_radius'; GEOM_MIN_BOUNDING_RADIUS: 'GEOM_MIN_BOUNDING_RADIUS' | 'geom_min_bounding_radius'; +GEOM_RELATE_PATTERN: 'GEOM_RELATE_PATTERN' | 'geom_relate_pattern'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; GEOM_CONTAINS: 'GEOM_CONTAINS' | 'geom_contains'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 62505d9aa6..119100de50 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -528,6 +528,7 @@ #include #include #include +#include #include #include #include @@ -11117,6 +11118,16 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(GeomMinBoundingRadiusLogicalFunction(std::move(arg0))); } /* END CODEGEN PARSER GLUE: GEOM_MIN_BOUNDING_RADIUS */ + case AntlrSQLParser::GEOM_RELATE_PATTERN: { + PRECONDITION(ctx->functionParam().size() == 3, + "GeomRelatePattern requires 3 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + return LogicalFunction(GeomRelatePatternLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); + } + /* END CODEGEN PARSER GLUE: GEOM_RELATE_PATTERN */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { PRECONDITION(ctx->functionParam().size() == 3, From 2ce00318a68c44e61acbd2da8c6a6215be1a767e Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Tue, 16 Jun 2026 06:21:46 +0200 Subject: [PATCH 84/86] feat(meos): add tgeo_tgeo 6-arg spatial predicate NES operators (W136) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wires 14 per-event operators for temporal geometry pairs — ever/always_eq/ne, eintersects/ecovers/edisjoint/econtains/etouches, aintersects/acovers/adisjoint/ acontains/atouches — as 6-arg (lon1,lat1,ts1:U64,lon2,lat2,ts2:U64) → FLOAT64 predicates backed by meos_geo_tgeo_tgeo functions. --- .../Meos/AcontainsTgeoTgeoLogicalFunction.hpp | 48 +++++ .../Meos/AcoversTgeoTgeoLogicalFunction.hpp | 48 +++++ .../Meos/AdisjointTgeoTgeoLogicalFunction.hpp | 48 +++++ .../AintersectsTgeoTgeoLogicalFunction.hpp | 48 +++++ .../Meos/AlwaysEqTgeoTgeoLogicalFunction.hpp | 48 +++++ .../Meos/AlwaysNeTgeoTgeoLogicalFunction.hpp | 48 +++++ .../Meos/AtouchesTgeoTgeoLogicalFunction.hpp | 48 +++++ .../Meos/EcontainsTgeoTgeoLogicalFunction.hpp | 48 +++++ .../Meos/EcoversTgeoTgeoLogicalFunction.hpp | 48 +++++ .../Meos/EdisjointTgeoTgeoLogicalFunction.hpp | 48 +++++ .../EintersectsTgeoTgeoLogicalFunction.hpp | 48 +++++ .../Meos/EtouchesTgeoTgeoLogicalFunction.hpp | 48 +++++ .../Meos/EverEqTgeoTgeoLogicalFunction.hpp | 48 +++++ .../Meos/EverNeTgeoTgeoLogicalFunction.hpp | 48 +++++ .../Meos/AcontainsTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../Meos/AcoversTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../Meos/AdisjointTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../AintersectsTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../Meos/AlwaysEqTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../Meos/AlwaysNeTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../Meos/AtouchesTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../src/Functions/Meos/CMakeLists.txt | 14 ++ .../Meos/EcontainsTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../Meos/EcoversTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../Meos/EdisjointTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../EintersectsTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../Meos/EtouchesTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../Meos/EverEqTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../Meos/EverNeTgeoTgeoLogicalFunction.cpp | 111 ++++++++++ .../AcontainsTgeoTgeoPhysicalFunction.hpp | 32 +++ .../Meos/AcoversTgeoTgeoPhysicalFunction.hpp | 32 +++ .../AdisjointTgeoTgeoPhysicalFunction.hpp | 32 +++ .../AintersectsTgeoTgeoPhysicalFunction.hpp | 32 +++ .../Meos/AlwaysEqTgeoTgeoPhysicalFunction.hpp | 32 +++ .../Meos/AlwaysNeTgeoTgeoPhysicalFunction.hpp | 32 +++ .../Meos/AtouchesTgeoTgeoPhysicalFunction.hpp | 32 +++ .../EcontainsTgeoTgeoPhysicalFunction.hpp | 32 +++ .../Meos/EcoversTgeoTgeoPhysicalFunction.hpp | 32 +++ .../EdisjointTgeoTgeoPhysicalFunction.hpp | 32 +++ .../EintersectsTgeoTgeoPhysicalFunction.hpp | 32 +++ .../Meos/EtouchesTgeoTgeoPhysicalFunction.hpp | 32 +++ .../Meos/EverEqTgeoTgeoPhysicalFunction.hpp | 32 +++ .../Meos/EverNeTgeoTgeoPhysicalFunction.hpp | 32 +++ .../AcontainsTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ .../Meos/AcoversTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ .../AdisjointTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ .../AintersectsTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ .../Meos/AlwaysEqTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ .../Meos/AlwaysNeTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ .../Meos/AtouchesTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ .../src/Functions/Meos/CMakeLists.txt | 14 ++ .../EcontainsTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ .../Meos/EcoversTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ .../EdisjointTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ .../EintersectsTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ .../Meos/EtouchesTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ .../Meos/EverEqTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ .../Meos/EverNeTgeoTgeoPhysicalFunction.cpp | 91 ++++++++ nes-sql-parser/AntlrSQL.g4 | 16 +- .../src/AntlrSQLQueryPlanCreator.cpp | 196 ++++++++++++++++++ 60 files changed, 4187 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AcontainsTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AcoversTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AdisjointTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AintersectsTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysEqTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AlwaysNeTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/AtouchesTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EcontainsTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EcoversTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EdisjointTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EintersectsTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EtouchesTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverEqTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EverNeTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AcontainsTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AcoversTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AdisjointTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AintersectsTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysEqTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AlwaysNeTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/AtouchesTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EcontainsTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EcoversTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EdisjointTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EintersectsTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EtouchesTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverEqTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EverNeTgeoTgeoLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AcontainsTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AcoversTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AdisjointTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AintersectsTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysEqTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AlwaysNeTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/AtouchesTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EcontainsTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EcoversTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EdisjointTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EintersectsTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EtouchesTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverEqTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EverNeTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AcontainsTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AcoversTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AdisjointTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AintersectsTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysEqTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AlwaysNeTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/AtouchesTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EcontainsTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EcoversTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EdisjointTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EintersectsTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EtouchesTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverEqTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EverNeTgeoTgeoPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AcontainsTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AcontainsTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..1a37399f4c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AcontainsTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether a temporal geometry always contains another. + */ +class AcontainsTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AcontainsTgeoTgeo"; + + AcontainsTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AcoversTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AcoversTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..52c370d0a6 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AcoversTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether a temporal geometry always covers another. + */ +class AcoversTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AcoversTgeoTgeo"; + + AcoversTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AdisjointTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AdisjointTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..80d2046dad --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AdisjointTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether two temporal geometries are always disjoint. + */ +class AdisjointTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AdisjointTgeoTgeo"; + + AdisjointTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AintersectsTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AintersectsTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..9958512ca8 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AintersectsTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether two temporal geometries always intersect. + */ +class AintersectsTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AintersectsTgeoTgeo"; + + AintersectsTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysEqTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysEqTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..49eb7868b3 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysEqTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether two temporal geometries are always spatially equal. + */ +class AlwaysEqTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysEqTgeoTgeo"; + + AlwaysEqTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AlwaysNeTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AlwaysNeTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..b2fa1d110b --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AlwaysNeTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether two temporal geometries are always spatially not equal. + */ +class AlwaysNeTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AlwaysNeTgeoTgeo"; + + AlwaysNeTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/AtouchesTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AtouchesTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..864f6c70c4 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AtouchesTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether two temporal geometries always touch. + */ +class AtouchesTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AtouchesTgeoTgeo"; + + AtouchesTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EcontainsTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EcontainsTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..41ea789905 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EcontainsTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether a temporal geometry ever contains another. + */ +class EcontainsTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EcontainsTgeoTgeo"; + + EcontainsTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EcoversTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EcoversTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..5bb9d7c90e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EcoversTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether a temporal geometry ever covers another. + */ +class EcoversTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EcoversTgeoTgeo"; + + EcoversTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EdisjointTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EdisjointTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..2c72e3220d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EdisjointTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether two temporal geometries are ever disjoint. + */ +class EdisjointTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EdisjointTgeoTgeo"; + + EdisjointTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EintersectsTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EintersectsTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..465e65ffa4 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EintersectsTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether two temporal geometries ever intersect. + */ +class EintersectsTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EintersectsTgeoTgeo"; + + EintersectsTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EtouchesTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EtouchesTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..39cdf9d376 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EtouchesTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether two temporal geometries ever touch. + */ +class EtouchesTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EtouchesTgeoTgeo"; + + EtouchesTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverEqTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverEqTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..e4fb3ca95d --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverEqTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether two temporal geometries are ever spatially equal. + */ +class EverEqTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverEqTgeoTgeo"; + + EverEqTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EverNeTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EverNeTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..5a46ad9201 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EverNeTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether two temporal geometries are ever spatially not equal. + */ +class EverNeTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EverNeTgeoTgeo"; + + EverNeTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AcontainsTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AcontainsTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..bf5ed84ba0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AcontainsTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AcontainsTgeoTgeoLogicalFunction::AcontainsTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType AcontainsTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AcontainsTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AcontainsTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AcontainsTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AcontainsTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AcontainsTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool AcontainsTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AcontainsTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AcontainsTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AcontainsTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAcontainsTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AcontainsTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AcontainsTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AcoversTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AcoversTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..fd3a00853d --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AcoversTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AcoversTgeoTgeoLogicalFunction::AcoversTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType AcoversTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AcoversTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AcoversTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AcoversTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AcoversTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AcoversTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool AcoversTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AcoversTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AcoversTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AcoversTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAcoversTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AcoversTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AcoversTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AdisjointTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AdisjointTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..688f46c35c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AdisjointTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AdisjointTgeoTgeoLogicalFunction::AdisjointTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType AdisjointTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AdisjointTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AdisjointTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AdisjointTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AdisjointTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AdisjointTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool AdisjointTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AdisjointTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AdisjointTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AdisjointTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAdisjointTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AdisjointTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AdisjointTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AintersectsTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AintersectsTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..e8475bd108 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AintersectsTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AintersectsTgeoTgeoLogicalFunction::AintersectsTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType AintersectsTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AintersectsTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AintersectsTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AintersectsTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AintersectsTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AintersectsTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool AintersectsTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AintersectsTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AintersectsTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AintersectsTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAintersectsTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AintersectsTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AintersectsTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysEqTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysEqTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..51aef4b50b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysEqTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysEqTgeoTgeoLogicalFunction::AlwaysEqTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType AlwaysEqTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysEqTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysEqTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysEqTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AlwaysEqTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysEqTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool AlwaysEqTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysEqTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysEqTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysEqTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysEqTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AlwaysEqTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AlwaysEqTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AlwaysNeTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AlwaysNeTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..4f4f13589e --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AlwaysNeTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AlwaysNeTgeoTgeoLogicalFunction::AlwaysNeTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType AlwaysNeTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AlwaysNeTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AlwaysNeTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AlwaysNeTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AlwaysNeTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AlwaysNeTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool AlwaysNeTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AlwaysNeTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AlwaysNeTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AlwaysNeTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAlwaysNeTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AlwaysNeTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AlwaysNeTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AtouchesTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AtouchesTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..2d3781a759 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AtouchesTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AtouchesTgeoTgeoLogicalFunction::AtouchesTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType AtouchesTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AtouchesTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AtouchesTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AtouchesTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "AtouchesTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AtouchesTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool AtouchesTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AtouchesTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AtouchesTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction AtouchesTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAtouchesTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "AtouchesTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return AtouchesTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 588f0630dd..5c1eb265f0 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -477,6 +477,20 @@ add_plugin(GeomFromHexewkb LogicalFunction nes-logical-operators GeomFromHexewkb add_plugin(GeoTransformPipeline LogicalFunction nes-logical-operators GeoTransformPipelineLogicalFunction.cpp) add_plugin(GeomMinBoundingCenter LogicalFunction nes-logical-operators GeomMinBoundingCenterLogicalFunction.cpp) add_plugin(GeomMinBoundingRadius LogicalFunction nes-logical-operators GeomMinBoundingRadiusLogicalFunction.cpp) +add_plugin(EverEqTgeoTgeo LogicalFunction nes-logical-operators EverEqTgeoTgeoLogicalFunction.cpp) +add_plugin(EverNeTgeoTgeo LogicalFunction nes-logical-operators EverNeTgeoTgeoLogicalFunction.cpp) +add_plugin(AlwaysEqTgeoTgeo LogicalFunction nes-logical-operators AlwaysEqTgeoTgeoLogicalFunction.cpp) +add_plugin(AlwaysNeTgeoTgeo LogicalFunction nes-logical-operators AlwaysNeTgeoTgeoLogicalFunction.cpp) +add_plugin(EintersectsTgeoTgeo LogicalFunction nes-logical-operators EintersectsTgeoTgeoLogicalFunction.cpp) +add_plugin(EcoversTgeoTgeo LogicalFunction nes-logical-operators EcoversTgeoTgeoLogicalFunction.cpp) +add_plugin(EdisjointTgeoTgeo LogicalFunction nes-logical-operators EdisjointTgeoTgeoLogicalFunction.cpp) +add_plugin(EcontainsTgeoTgeo LogicalFunction nes-logical-operators EcontainsTgeoTgeoLogicalFunction.cpp) +add_plugin(EtouchesTgeoTgeo LogicalFunction nes-logical-operators EtouchesTgeoTgeoLogicalFunction.cpp) +add_plugin(AintersectsTgeoTgeo LogicalFunction nes-logical-operators AintersectsTgeoTgeoLogicalFunction.cpp) +add_plugin(AcoversTgeoTgeo LogicalFunction nes-logical-operators AcoversTgeoTgeoLogicalFunction.cpp) +add_plugin(AdisjointTgeoTgeo LogicalFunction nes-logical-operators AdisjointTgeoTgeoLogicalFunction.cpp) +add_plugin(AcontainsTgeoTgeo LogicalFunction nes-logical-operators AcontainsTgeoTgeoLogicalFunction.cpp) +add_plugin(AtouchesTgeoTgeo LogicalFunction nes-logical-operators AtouchesTgeoTgeoLogicalFunction.cpp) add_plugin(GeomRelatePattern LogicalFunction nes-logical-operators GeomRelatePatternLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EcontainsTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EcontainsTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..955ec62f67 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EcontainsTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EcontainsTgeoTgeoLogicalFunction::EcontainsTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType EcontainsTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EcontainsTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EcontainsTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EcontainsTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EcontainsTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EcontainsTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool EcontainsTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EcontainsTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EcontainsTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EcontainsTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEcontainsTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EcontainsTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EcontainsTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EcoversTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EcoversTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..f060447b1a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EcoversTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EcoversTgeoTgeoLogicalFunction::EcoversTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType EcoversTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EcoversTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EcoversTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EcoversTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EcoversTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EcoversTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool EcoversTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EcoversTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EcoversTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EcoversTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEcoversTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EcoversTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EcoversTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EdisjointTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EdisjointTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..157a6a264a --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EdisjointTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EdisjointTgeoTgeoLogicalFunction::EdisjointTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType EdisjointTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EdisjointTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EdisjointTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EdisjointTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EdisjointTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EdisjointTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool EdisjointTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EdisjointTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EdisjointTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EdisjointTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEdisjointTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EdisjointTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EdisjointTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EintersectsTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EintersectsTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..2a597066f8 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EintersectsTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EintersectsTgeoTgeoLogicalFunction::EintersectsTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType EintersectsTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EintersectsTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EintersectsTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EintersectsTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EintersectsTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EintersectsTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool EintersectsTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EintersectsTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EintersectsTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EintersectsTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEintersectsTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EintersectsTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EintersectsTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EtouchesTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EtouchesTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..0aac78792c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EtouchesTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EtouchesTgeoTgeoLogicalFunction::EtouchesTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType EtouchesTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EtouchesTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EtouchesTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EtouchesTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EtouchesTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EtouchesTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool EtouchesTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EtouchesTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EtouchesTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EtouchesTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEtouchesTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EtouchesTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EtouchesTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverEqTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverEqTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..d5c28eae46 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverEqTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverEqTgeoTgeoLogicalFunction::EverEqTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType EverEqTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverEqTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverEqTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverEqTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EverEqTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverEqTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool EverEqTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverEqTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverEqTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverEqTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverEqTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EverEqTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EverEqTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/EverNeTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EverNeTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..d30c830b71 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EverNeTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,111 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EverNeTgeoTgeoLogicalFunction::EverNeTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(6); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); +} + +DataType EverNeTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EverNeTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EverNeTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EverNeTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 6, + "EverNeTgeoTgeoLogicalFunction requires 6 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EverNeTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool EverNeTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EverNeTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EverNeTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(6); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + return withChildren(c); +} + +SerializableFunction EverNeTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEverNeTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 6, + "EverNeTgeoTgeoLogicalFunction requires 6 children but got {}", + arguments.children.size()); + return EverNeTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AcontainsTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AcontainsTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..5c3bf5237f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AcontainsTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AcontainsTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AcontainsTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AcoversTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AcoversTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..298e0f13b1 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AcoversTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AcoversTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AcoversTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AdisjointTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AdisjointTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..c5fea46730 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AdisjointTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AdisjointTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AdisjointTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AintersectsTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AintersectsTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..5359651e51 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AintersectsTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AintersectsTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AintersectsTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysEqTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysEqTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..8a48929cf6 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysEqTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysEqTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysEqTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AlwaysNeTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AlwaysNeTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..888863999f --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AlwaysNeTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AlwaysNeTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AlwaysNeTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AtouchesTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AtouchesTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..f4f472222d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AtouchesTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AtouchesTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AtouchesTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EcontainsTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EcontainsTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..56f7b49cc8 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EcontainsTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EcontainsTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EcontainsTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EcoversTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EcoversTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..28b70fad9b --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EcoversTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EcoversTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EcoversTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EdisjointTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EdisjointTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..80c52445ec --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EdisjointTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EdisjointTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EdisjointTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EintersectsTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EintersectsTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..5059b28ad4 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EintersectsTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EintersectsTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EintersectsTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EtouchesTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EtouchesTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..464922ce60 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EtouchesTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EtouchesTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EtouchesTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverEqTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverEqTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..5571b9a7fe --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverEqTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverEqTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EverEqTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EverNeTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EverNeTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..7d7e4b4280 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EverNeTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EverNeTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EverNeTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AcontainsTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AcontainsTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..5bacc09a11 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AcontainsTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AcontainsTgeoTgeoPhysicalFunction::AcontainsTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AcontainsTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = acontains_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAcontainsTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AcontainsTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AcontainsTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AcoversTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AcoversTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..8898176bd1 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AcoversTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AcoversTgeoTgeoPhysicalFunction::AcoversTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AcoversTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = acovers_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAcoversTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AcoversTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AcoversTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AdisjointTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AdisjointTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..aeba15bf79 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AdisjointTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AdisjointTgeoTgeoPhysicalFunction::AdisjointTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AdisjointTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = adisjoint_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAdisjointTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AdisjointTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AdisjointTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AintersectsTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AintersectsTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..8ddff7ddee --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AintersectsTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AintersectsTgeoTgeoPhysicalFunction::AintersectsTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AintersectsTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = aintersects_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAintersectsTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AintersectsTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AintersectsTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysEqTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysEqTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..5a019e301f --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysEqTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysEqTgeoTgeoPhysicalFunction::AlwaysEqTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AlwaysEqTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = always_eq_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysEqTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AlwaysEqTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AlwaysEqTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AlwaysNeTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AlwaysNeTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..bd05ab175c --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AlwaysNeTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AlwaysNeTgeoTgeoPhysicalFunction::AlwaysNeTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AlwaysNeTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = always_ne_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAlwaysNeTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AlwaysNeTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AlwaysNeTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AtouchesTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AtouchesTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..30434656d5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AtouchesTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AtouchesTgeoTgeoPhysicalFunction::AtouchesTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal AtouchesTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = atouches_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAtouchesTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "AtouchesTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return AtouchesTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 9b98275811..a928b78345 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -476,6 +476,20 @@ add_plugin(GeomFromHexewkb PhysicalFunction nes-physical-operators GeomFromHexew add_plugin(GeoTransformPipeline PhysicalFunction nes-physical-operators GeoTransformPipelinePhysicalFunction.cpp) add_plugin(GeomMinBoundingCenter PhysicalFunction nes-physical-operators GeomMinBoundingCenterPhysicalFunction.cpp) add_plugin(GeomMinBoundingRadius PhysicalFunction nes-physical-operators GeomMinBoundingRadiusPhysicalFunction.cpp) +add_plugin(EverEqTgeoTgeo PhysicalFunction nes-physical-operators EverEqTgeoTgeoPhysicalFunction.cpp) +add_plugin(EverNeTgeoTgeo PhysicalFunction nes-physical-operators EverNeTgeoTgeoPhysicalFunction.cpp) +add_plugin(AlwaysEqTgeoTgeo PhysicalFunction nes-physical-operators AlwaysEqTgeoTgeoPhysicalFunction.cpp) +add_plugin(AlwaysNeTgeoTgeo PhysicalFunction nes-physical-operators AlwaysNeTgeoTgeoPhysicalFunction.cpp) +add_plugin(EintersectsTgeoTgeo PhysicalFunction nes-physical-operators EintersectsTgeoTgeoPhysicalFunction.cpp) +add_plugin(EcoversTgeoTgeo PhysicalFunction nes-physical-operators EcoversTgeoTgeoPhysicalFunction.cpp) +add_plugin(EdisjointTgeoTgeo PhysicalFunction nes-physical-operators EdisjointTgeoTgeoPhysicalFunction.cpp) +add_plugin(EcontainsTgeoTgeo PhysicalFunction nes-physical-operators EcontainsTgeoTgeoPhysicalFunction.cpp) +add_plugin(EtouchesTgeoTgeo PhysicalFunction nes-physical-operators EtouchesTgeoTgeoPhysicalFunction.cpp) +add_plugin(AintersectsTgeoTgeo PhysicalFunction nes-physical-operators AintersectsTgeoTgeoPhysicalFunction.cpp) +add_plugin(AcoversTgeoTgeo PhysicalFunction nes-physical-operators AcoversTgeoTgeoPhysicalFunction.cpp) +add_plugin(AdisjointTgeoTgeo PhysicalFunction nes-physical-operators AdisjointTgeoTgeoPhysicalFunction.cpp) +add_plugin(AcontainsTgeoTgeo PhysicalFunction nes-physical-operators AcontainsTgeoTgeoPhysicalFunction.cpp) +add_plugin(AtouchesTgeoTgeo PhysicalFunction nes-physical-operators AtouchesTgeoTgeoPhysicalFunction.cpp) add_plugin(GeomRelatePattern PhysicalFunction nes-physical-operators GeomRelatePatternPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EcontainsTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EcontainsTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..5ca82ffa6d --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EcontainsTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EcontainsTgeoTgeoPhysicalFunction::EcontainsTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EcontainsTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = econtains_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEcontainsTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EcontainsTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EcontainsTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EcoversTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EcoversTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..dd35059bc7 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EcoversTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EcoversTgeoTgeoPhysicalFunction::EcoversTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EcoversTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = ecovers_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEcoversTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EcoversTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EcoversTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EdisjointTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EdisjointTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..1708e377b0 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EdisjointTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EdisjointTgeoTgeoPhysicalFunction::EdisjointTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EdisjointTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = edisjoint_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEdisjointTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EdisjointTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EdisjointTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EintersectsTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EintersectsTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..f1b9a19f49 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EintersectsTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EintersectsTgeoTgeoPhysicalFunction::EintersectsTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EintersectsTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = eintersects_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEintersectsTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EintersectsTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EintersectsTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EtouchesTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EtouchesTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..502df9fc65 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EtouchesTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EtouchesTgeoTgeoPhysicalFunction::EtouchesTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EtouchesTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = etouches_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEtouchesTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EtouchesTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EtouchesTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverEqTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverEqTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..101c1833ed --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverEqTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverEqTgeoTgeoPhysicalFunction::EverEqTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EverEqTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = ever_eq_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverEqTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EverEqTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EverEqTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/EverNeTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EverNeTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..07e36fb39e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EverNeTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,91 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EverNeTgeoTgeoPhysicalFunction::EverNeTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2) +{ + paramFns.reserve(6); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); +} + +VarVal EverNeTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = ever_ne_tgeo_tgeo(t1, t2); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEverNeTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 6, + "EverNeTgeoTgeoPhysicalFunction requires 6 children but got {}", + arguments.childFunctions.size()); + return EverNeTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index a85c3c142b..a9615339df 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_POINT_MAKE2D | GEOM_POINT_MAKE3DZ | GEOG_POINT_MAKE2D | GEOG_POINT_MAKE3DZ | GEOM_TO_GEOG | GEOG_TO_GEOM | GEOG_CENTROID | GEO_GEO_N | LINE_POINT_N | GEOM_INTERSECTION2D_COLL | GEO_AS_GEOJSON | GEO_AS_HEXEWKB | GEO_AS_EWKT | GEO_FROM_GEOJSON | GEOM_FROM_HEXEWKB | GEO_TRANSFORM_PIPELINE | GEOM_MIN_BOUNDING_CENTER | GEOM_MIN_BOUNDING_RADIUS | GEOM_RELATE_PATTERN | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_POINT_MAKE2D | GEOM_POINT_MAKE3DZ | GEOG_POINT_MAKE2D | GEOG_POINT_MAKE3DZ | GEOM_TO_GEOG | GEOG_TO_GEOM | GEOG_CENTROID | GEO_GEO_N | LINE_POINT_N | GEOM_INTERSECTION2D_COLL | GEO_AS_GEOJSON | GEO_AS_HEXEWKB | GEO_AS_EWKT | GEO_FROM_GEOJSON | GEOM_FROM_HEXEWKB | GEO_TRANSFORM_PIPELINE | GEOM_MIN_BOUNDING_CENTER | GEOM_MIN_BOUNDING_RADIUS | EVER_EQ_TGEO_TGEO | EVER_NE_TGEO_TGEO | ALWAYS_EQ_TGEO_TGEO | ALWAYS_NE_TGEO_TGEO | EINTERSECTS_TGEO_TGEO | ECOVERS_TGEO_TGEO | EDISJOINT_TGEO_TGEO | ECONTAINS_TGEO_TGEO | ETOUCHES_TGEO_TGEO | AINTERSECTS_TGEO_TGEO | ACOVERS_TGEO_TGEO | ADISJOINT_TGEO_TGEO | ACONTAINS_TGEO_TGEO | ATOUCHES_TGEO_TGEO | GEOM_RELATE_PATTERN | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -947,6 +947,20 @@ GEOM_FROM_HEXEWKB: 'GEOM_FROM_HEXEWKB' | 'geom_from_hexewkb'; GEO_TRANSFORM_PIPELINE: 'GEO_TRANSFORM_PIPELINE' | 'geo_transform_pipeline'; GEOM_MIN_BOUNDING_CENTER: 'GEOM_MIN_BOUNDING_CENTER' | 'geom_min_bounding_radius'; GEOM_MIN_BOUNDING_RADIUS: 'GEOM_MIN_BOUNDING_RADIUS' | 'geom_min_bounding_radius'; +EVER_EQ_TGEO_TGEO: 'EVER_EQ_TGEO_TGEO' | 'ever_eq_tgeo_tgeo'; +EVER_NE_TGEO_TGEO: 'EVER_NE_TGEO_TGEO' | 'ever_ne_tgeo_tgeo'; +ALWAYS_EQ_TGEO_TGEO: 'ALWAYS_EQ_TGEO_TGEO' | 'always_eq_tgeo_tgeo'; +ALWAYS_NE_TGEO_TGEO: 'ALWAYS_NE_TGEO_TGEO' | 'always_ne_tgeo_tgeo'; +EINTERSECTS_TGEO_TGEO: 'EINTERSECTS_TGEO_TGEO' | 'eintersects_tgeo_tgeo'; +ECOVERS_TGEO_TGEO: 'ECOVERS_TGEO_TGEO' | 'ecovers_tgeo_tgeo'; +EDISJOINT_TGEO_TGEO: 'EDISJOINT_TGEO_TGEO' | 'edisjoint_tgeo_tgeo'; +ECONTAINS_TGEO_TGEO: 'ECONTAINS_TGEO_TGEO' | 'econtains_tgeo_tgeo'; +ETOUCHES_TGEO_TGEO: 'ETOUCHES_TGEO_TGEO' | 'etouches_tgeo_tgeo'; +AINTERSECTS_TGEO_TGEO: 'AINTERSECTS_TGEO_TGEO' | 'aintersects_tgeo_tgeo'; +ACOVERS_TGEO_TGEO: 'ACOVERS_TGEO_TGEO' | 'acovers_tgeo_tgeo'; +ADISJOINT_TGEO_TGEO: 'ADISJOINT_TGEO_TGEO' | 'adisjoint_tgeo_tgeo'; +ACONTAINS_TGEO_TGEO: 'ACONTAINS_TGEO_TGEO' | 'acontains_tgeo_tgeo'; +ATOUCHES_TGEO_TGEO: 'ATOUCHES_TGEO_TGEO' | 'atouches_tgeo_tgeo'; GEOM_RELATE_PATTERN: 'GEOM_RELATE_PATTERN' | 'geom_relate_pattern'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 119100de50..9297faa125 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -528,6 +528,20 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -11127,6 +11141,188 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont auto arg2 = visit(ctx->functionParam(2)).as(); return LogicalFunction(GeomRelatePatternLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2))); } + case AntlrSQLParser::EVER_EQ_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "EverEqTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EverEqTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: EVER_EQ_TGEO_TGEO */ + case AntlrSQLParser::EVER_NE_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "EverNeTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EverNeTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: EVER_NE_TGEO_TGEO */ + case AntlrSQLParser::ALWAYS_EQ_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "AlwaysEqTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AlwaysEqTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_EQ_TGEO_TGEO */ + case AntlrSQLParser::ALWAYS_NE_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "AlwaysNeTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AlwaysNeTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ALWAYS_NE_TGEO_TGEO */ + case AntlrSQLParser::EINTERSECTS_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "EintersectsTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EintersectsTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: EINTERSECTS_TGEO_TGEO */ + case AntlrSQLParser::ECOVERS_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "EcoversTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EcoversTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ECOVERS_TGEO_TGEO */ + case AntlrSQLParser::EDISJOINT_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "EdisjointTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EdisjointTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: EDISJOINT_TGEO_TGEO */ + case AntlrSQLParser::ECONTAINS_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "EcontainsTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EcontainsTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ECONTAINS_TGEO_TGEO */ + case AntlrSQLParser::ETOUCHES_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "EtouchesTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(EtouchesTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ETOUCHES_TGEO_TGEO */ + case AntlrSQLParser::AINTERSECTS_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "AintersectsTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AintersectsTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: AINTERSECTS_TGEO_TGEO */ + case AntlrSQLParser::ACOVERS_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "AcoversTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AcoversTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ACOVERS_TGEO_TGEO */ + case AntlrSQLParser::ADISJOINT_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "AdisjointTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AdisjointTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ADISJOINT_TGEO_TGEO */ + case AntlrSQLParser::ACONTAINS_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "AcontainsTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AcontainsTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ACONTAINS_TGEO_TGEO */ + case AntlrSQLParser::ATOUCHES_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 6, + "AtouchesTgeoTgeo requires 6 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + return LogicalFunction(AtouchesTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); + } + /* END CODEGEN PARSER GLUE: ATOUCHES_TGEO_TGEO */ /* END CODEGEN PARSER GLUE: GEOM_RELATE_PATTERN */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { From 6962c70de9946d6c8090109b27e678e999d9f8d5 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Tue, 16 Jun 2026 06:23:14 +0200 Subject: [PATCH 85/86] feat(meos): add tgeo_tgeo 7-arg dwithin NES operators (W137) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wires EDWITHIN_TGEO_TGEO and ADWITHIN_TGEO_TGEO as 7-arg (lon1,lat1,ts1:U64,lon2,lat2,ts2:U64,dist:F64) → FLOAT64 predicates backed by edwithin_tgeo_tgeo / adwithin_tgeo_tgeo. Completes the tgeo_tgeo predicate family in MobilityNebula. --- .../Meos/AdwithinTgeoTgeoLogicalFunction.hpp | 48 ++++++++ .../Meos/EdwithinTgeoTgeoLogicalFunction.hpp | 48 ++++++++ .../Meos/AdwithinTgeoTgeoLogicalFunction.cpp | 114 ++++++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../Meos/EdwithinTgeoTgeoLogicalFunction.cpp | 114 ++++++++++++++++++ .../Meos/AdwithinTgeoTgeoPhysicalFunction.hpp | 32 +++++ .../Meos/EdwithinTgeoTgeoPhysicalFunction.hpp | 32 +++++ .../Meos/AdwithinTgeoTgeoPhysicalFunction.cpp | 95 +++++++++++++++ .../src/Functions/Meos/CMakeLists.txt | 2 + .../Meos/EdwithinTgeoTgeoPhysicalFunction.cpp | 95 +++++++++++++++ nes-sql-parser/AntlrSQL.g4 | 4 +- .../src/AntlrSQLQueryPlanCreator.cpp | 30 +++++ 12 files changed, 615 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/AdwithinTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/EdwithinTgeoTgeoLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/AdwithinTgeoTgeoLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/EdwithinTgeoTgeoLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/AdwithinTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/EdwithinTgeoTgeoPhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/AdwithinTgeoTgeoPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/EdwithinTgeoTgeoPhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/AdwithinTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/AdwithinTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..689bdfbfda --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/AdwithinTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether two temporal geometries are always within a distance. + */ +class AdwithinTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "AdwithinTgeoTgeo"; + + AdwithinTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2, LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/EdwithinTgeoTgeoLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/EdwithinTgeoTgeoLogicalFunction.hpp new file mode 100644 index 0000000000..d6467a606e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/EdwithinTgeoTgeoLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests whether two temporal geometries are ever within a distance. + */ +class EdwithinTgeoTgeoLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "EdwithinTgeoTgeo"; + + EdwithinTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2, LogicalFunction dist); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/AdwithinTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/AdwithinTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..56de5e2ca4 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/AdwithinTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,114 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +AdwithinTgeoTgeoLogicalFunction::AdwithinTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2, LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); + parameters.push_back(std::move(dist)); +} + +DataType AdwithinTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction AdwithinTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector AdwithinTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction AdwithinTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "AdwithinTgeoTgeoLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view AdwithinTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool AdwithinTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string AdwithinTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction AdwithinTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "dist must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction AdwithinTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterAdwithinTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "AdwithinTgeoTgeoLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return AdwithinTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 5c1eb265f0..8f922b7599 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -491,6 +491,8 @@ add_plugin(AcoversTgeoTgeo LogicalFunction nes-logical-operators AcoversTgeoTgeo add_plugin(AdisjointTgeoTgeo LogicalFunction nes-logical-operators AdisjointTgeoTgeoLogicalFunction.cpp) add_plugin(AcontainsTgeoTgeo LogicalFunction nes-logical-operators AcontainsTgeoTgeoLogicalFunction.cpp) add_plugin(AtouchesTgeoTgeo LogicalFunction nes-logical-operators AtouchesTgeoTgeoLogicalFunction.cpp) +add_plugin(EdwithinTgeoTgeo LogicalFunction nes-logical-operators EdwithinTgeoTgeoLogicalFunction.cpp) +add_plugin(AdwithinTgeoTgeo LogicalFunction nes-logical-operators AdwithinTgeoTgeoLogicalFunction.cpp) add_plugin(GeomRelatePattern LogicalFunction nes-logical-operators GeomRelatePatternLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/EdwithinTgeoTgeoLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/EdwithinTgeoTgeoLogicalFunction.cpp new file mode 100644 index 0000000000..1a116ae236 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/EdwithinTgeoTgeoLogicalFunction.cpp @@ -0,0 +1,114 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +EdwithinTgeoTgeoLogicalFunction::EdwithinTgeoTgeoLogicalFunction(LogicalFunction lon1, LogicalFunction lat1, LogicalFunction ts1, LogicalFunction lon2, LogicalFunction lat2, LogicalFunction ts2, LogicalFunction dist) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(7); + parameters.push_back(std::move(lon1)); + parameters.push_back(std::move(lat1)); + parameters.push_back(std::move(ts1)); + parameters.push_back(std::move(lon2)); + parameters.push_back(std::move(lat2)); + parameters.push_back(std::move(ts2)); + parameters.push_back(std::move(dist)); +} + +DataType EdwithinTgeoTgeoLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction EdwithinTgeoTgeoLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector EdwithinTgeoTgeoLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction EdwithinTgeoTgeoLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 7, + "EdwithinTgeoTgeoLogicalFunction requires 7 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view EdwithinTgeoTgeoLogicalFunction::getType() const { return NAME; } + +bool EdwithinTgeoTgeoLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string EdwithinTgeoTgeoLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction EdwithinTgeoTgeoLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(7); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::FLOAT64), "lon1 must be FLOAT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::FLOAT64), "lat1 must be FLOAT64"); + INVARIANT(c[2].getDataType().isType(DataType::Type::UINT64), "ts1 must be UINT64"); + INVARIANT(c[3].getDataType().isType(DataType::Type::FLOAT64), "lon2 must be FLOAT64"); + INVARIANT(c[4].getDataType().isType(DataType::Type::FLOAT64), "lat2 must be FLOAT64"); + INVARIANT(c[5].getDataType().isType(DataType::Type::UINT64), "ts2 must be UINT64"); + INVARIANT(c[6].getDataType().isType(DataType::Type::FLOAT64), "dist must be FLOAT64"); + return withChildren(c); +} + +SerializableFunction EdwithinTgeoTgeoLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterEdwithinTgeoTgeoLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 7, + "EdwithinTgeoTgeoLogicalFunction requires 7 children but got {}", + arguments.children.size()); + return EdwithinTgeoTgeoLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1]), + std::move(arguments.children[2]), + std::move(arguments.children[3]), + std::move(arguments.children[4]), + std::move(arguments.children[5]), + std::move(arguments.children[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/AdwithinTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/AdwithinTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..4f171e71ad --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/AdwithinTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class AdwithinTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + AdwithinTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2, PhysicalFunction dist); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/EdwithinTgeoTgeoPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/EdwithinTgeoTgeoPhysicalFunction.hpp new file mode 100644 index 0000000000..41509fbd7d --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/EdwithinTgeoTgeoPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class EdwithinTgeoTgeoPhysicalFunction : public PhysicalFunctionConcept { +public: + EdwithinTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2, PhysicalFunction dist); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/AdwithinTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/AdwithinTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..fdcebcbde5 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/AdwithinTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +AdwithinTgeoTgeoPhysicalFunction::AdwithinTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2, PhysicalFunction dist) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); + paramFns.push_back(std::move(dist)); +} + +VarVal AdwithinTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + auto dist = paramFns[6].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2, + double dist) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = adwithin_tgeo_tgeo(t1, t2, dist); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2, dist); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterAdwithinTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "AdwithinTgeoTgeoPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return AdwithinTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index a928b78345..49ed24d7dd 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -490,6 +490,8 @@ add_plugin(AcoversTgeoTgeo PhysicalFunction nes-physical-operators AcoversTgeoTg add_plugin(AdisjointTgeoTgeo PhysicalFunction nes-physical-operators AdisjointTgeoTgeoPhysicalFunction.cpp) add_plugin(AcontainsTgeoTgeo PhysicalFunction nes-physical-operators AcontainsTgeoTgeoPhysicalFunction.cpp) add_plugin(AtouchesTgeoTgeo PhysicalFunction nes-physical-operators AtouchesTgeoTgeoPhysicalFunction.cpp) +add_plugin(EdwithinTgeoTgeo PhysicalFunction nes-physical-operators EdwithinTgeoTgeoPhysicalFunction.cpp) +add_plugin(AdwithinTgeoTgeo PhysicalFunction nes-physical-operators AdwithinTgeoTgeoPhysicalFunction.cpp) add_plugin(GeomRelatePattern PhysicalFunction nes-physical-operators GeomRelatePatternPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/EdwithinTgeoTgeoPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/EdwithinTgeoTgeoPhysicalFunction.cpp new file mode 100644 index 0000000000..96a13325fc --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/EdwithinTgeoTgeoPhysicalFunction.cpp @@ -0,0 +1,95 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +EdwithinTgeoTgeoPhysicalFunction::EdwithinTgeoTgeoPhysicalFunction(PhysicalFunction lon1, PhysicalFunction lat1, PhysicalFunction ts1, PhysicalFunction lon2, PhysicalFunction lat2, PhysicalFunction ts2, PhysicalFunction dist) +{ + paramFns.reserve(7); + paramFns.push_back(std::move(lon1)); + paramFns.push_back(std::move(lat1)); + paramFns.push_back(std::move(ts1)); + paramFns.push_back(std::move(lon2)); + paramFns.push_back(std::move(lat2)); + paramFns.push_back(std::move(ts2)); + paramFns.push_back(std::move(dist)); +} + +VarVal EdwithinTgeoTgeoPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto lon1 = paramFns[0].execute(record, arena).cast(); + auto lat1 = paramFns[1].execute(record, arena).cast(); + auto ts1 = paramFns[2].execute(record, arena).cast(); + auto lon2 = paramFns[3].execute(record, arena).cast(); + auto lat2 = paramFns[4].execute(record, arena).cast(); + auto ts2 = paramFns[5].execute(record, arena).cast(); + auto dist = paramFns[6].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](double lon1, double lat1, uint64_t ts1, + double lon2, double lat2, uint64_t ts2, + double dist) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + std::string wkt1 = fmt::format("SRID=4326;POINT({},{})@{}", lon1, lat1, ts1); + Temporal* t1 = tgeompoint_in(wkt1.c_str()); + if (!t1) return 0.0; + std::string wkt2 = fmt::format("SRID=4326;POINT({},{})@{}", lon2, lat2, ts2); + Temporal* t2 = tgeompoint_in(wkt2.c_str()); + if (!t2) { free(t1); return 0.0; } + int r = edwithin_tgeo_tgeo(t1, t2, dist); + free(t1); free(t2); + return r > 0 ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + lon1, lat1, ts1, lon2, lat2, ts2, dist); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterEdwithinTgeoTgeoPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 7, + "EdwithinTgeoTgeoPhysicalFunction requires 7 children but got {}", + arguments.childFunctions.size()); + return EdwithinTgeoTgeoPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1]), + std::move(arguments.childFunctions[2]), + std::move(arguments.childFunctions[3]), + std::move(arguments.childFunctions[4]), + std::move(arguments.childFunctions[5]), + std::move(arguments.childFunctions[6])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index a9615339df..0e6b471cba 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_POINT_MAKE2D | GEOM_POINT_MAKE3DZ | GEOG_POINT_MAKE2D | GEOG_POINT_MAKE3DZ | GEOM_TO_GEOG | GEOG_TO_GEOM | GEOG_CENTROID | GEO_GEO_N | LINE_POINT_N | GEOM_INTERSECTION2D_COLL | GEO_AS_GEOJSON | GEO_AS_HEXEWKB | GEO_AS_EWKT | GEO_FROM_GEOJSON | GEOM_FROM_HEXEWKB | GEO_TRANSFORM_PIPELINE | GEOM_MIN_BOUNDING_CENTER | GEOM_MIN_BOUNDING_RADIUS | EVER_EQ_TGEO_TGEO | EVER_NE_TGEO_TGEO | ALWAYS_EQ_TGEO_TGEO | ALWAYS_NE_TGEO_TGEO | EINTERSECTS_TGEO_TGEO | ECOVERS_TGEO_TGEO | EDISJOINT_TGEO_TGEO | ECONTAINS_TGEO_TGEO | ETOUCHES_TGEO_TGEO | AINTERSECTS_TGEO_TGEO | ACOVERS_TGEO_TGEO | ADISJOINT_TGEO_TGEO | ACONTAINS_TGEO_TGEO | ATOUCHES_TGEO_TGEO | GEOM_RELATE_PATTERN | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_POINT_MAKE2D | GEOM_POINT_MAKE3DZ | GEOG_POINT_MAKE2D | GEOG_POINT_MAKE3DZ | GEOM_TO_GEOG | GEOG_TO_GEOM | GEOG_CENTROID | GEO_GEO_N | LINE_POINT_N | GEOM_INTERSECTION2D_COLL | GEO_AS_GEOJSON | GEO_AS_HEXEWKB | GEO_AS_EWKT | GEO_FROM_GEOJSON | GEOM_FROM_HEXEWKB | GEO_TRANSFORM_PIPELINE | GEOM_MIN_BOUNDING_CENTER | GEOM_MIN_BOUNDING_RADIUS | EVER_EQ_TGEO_TGEO | EVER_NE_TGEO_TGEO | ALWAYS_EQ_TGEO_TGEO | ALWAYS_NE_TGEO_TGEO | EINTERSECTS_TGEO_TGEO | ECOVERS_TGEO_TGEO | EDISJOINT_TGEO_TGEO | ECONTAINS_TGEO_TGEO | ETOUCHES_TGEO_TGEO | AINTERSECTS_TGEO_TGEO | ACOVERS_TGEO_TGEO | ADISJOINT_TGEO_TGEO | ACONTAINS_TGEO_TGEO | ATOUCHES_TGEO_TGEO | EDWITHIN_TGEO_TGEO | ADWITHIN_TGEO_TGEO | GEOM_RELATE_PATTERN | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -961,6 +961,8 @@ ACOVERS_TGEO_TGEO: 'ACOVERS_TGEO_TGEO' | 'acovers_tgeo_tgeo'; ADISJOINT_TGEO_TGEO: 'ADISJOINT_TGEO_TGEO' | 'adisjoint_tgeo_tgeo'; ACONTAINS_TGEO_TGEO: 'ACONTAINS_TGEO_TGEO' | 'acontains_tgeo_tgeo'; ATOUCHES_TGEO_TGEO: 'ATOUCHES_TGEO_TGEO' | 'atouches_tgeo_tgeo'; +EDWITHIN_TGEO_TGEO: 'EDWITHIN_TGEO_TGEO' | 'edwithin_tgeo_tgeo'; +ADWITHIN_TGEO_TGEO: 'ADWITHIN_TGEO_TGEO' | 'adwithin_tgeo_tgeo'; GEOM_RELATE_PATTERN: 'GEOM_RELATE_PATTERN' | 'geom_relate_pattern'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 9297faa125..9ae515ab44 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -542,6 +542,8 @@ #include #include #include +#include +#include #include #include #include @@ -11323,6 +11325,34 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(AtouchesTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5))); } /* END CODEGEN PARSER GLUE: ATOUCHES_TGEO_TGEO */ + case AntlrSQLParser::EDWITHIN_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 7, + "EdwithinTgeoTgeo requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(EdwithinTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: EDWITHIN_TGEO_TGEO */ + case AntlrSQLParser::ADWITHIN_TGEO_TGEO: { + PRECONDITION(ctx->functionParam().size() == 7, + "AdwithinTgeoTgeo requires 7 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + auto arg2 = visit(ctx->functionParam(2)).as(); + auto arg3 = visit(ctx->functionParam(3)).as(); + auto arg4 = visit(ctx->functionParam(4)).as(); + auto arg5 = visit(ctx->functionParam(5)).as(); + auto arg6 = visit(ctx->functionParam(6)).as(); + return LogicalFunction(AdwithinTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); + } + /* END CODEGEN PARSER GLUE: ADWITHIN_TGEO_TGEO */ /* END CODEGEN PARSER GLUE: GEOM_RELATE_PATTERN */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: { From 8abdb25490da2b7b139a44135e24c3cffd03f281 Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Thu, 18 Jun 2026 13:02:36 +0200 Subject: [PATCH 86/86] feat(meos): add H3Index static comparator NES operators (W138) Wires H3INDEX_EQ, H3INDEX_NE, H3INDEX_LT, H3INDEX_LE, H3INDEX_GT, H3INDEX_GE, and H3INDEX_CMP as 2-arg (a:UINT64, b:UINT64) -> FLOAT64 operators backed by h3index_eq/ne/lt/le/gt/ge (bool -> 0.0/1.0) and h3index_cmp (int -> -1.0/0.0/1.0). New in pin ecosystem-pin-2026-06-18b. --- .../Meos/H3indexCmpLogicalFunction.hpp | 48 +++++++++ .../Meos/H3indexEqLogicalFunction.hpp | 48 +++++++++ .../Meos/H3indexGeLogicalFunction.hpp | 48 +++++++++ .../Meos/H3indexGtLogicalFunction.hpp | 48 +++++++++ .../Meos/H3indexLeLogicalFunction.hpp | 48 +++++++++ .../Meos/H3indexLtLogicalFunction.hpp | 48 +++++++++ .../Meos/H3indexNeLogicalFunction.hpp | 48 +++++++++ .../src/Functions/Meos/CMakeLists.txt | 7 ++ .../Meos/H3indexCmpLogicalFunction.cpp | 99 +++++++++++++++++++ .../Meos/H3indexEqLogicalFunction.cpp | 99 +++++++++++++++++++ .../Meos/H3indexGeLogicalFunction.cpp | 99 +++++++++++++++++++ .../Meos/H3indexGtLogicalFunction.cpp | 99 +++++++++++++++++++ .../Meos/H3indexLeLogicalFunction.cpp | 99 +++++++++++++++++++ .../Meos/H3indexLtLogicalFunction.cpp | 99 +++++++++++++++++++ .../Meos/H3indexNeLogicalFunction.cpp | 99 +++++++++++++++++++ .../Meos/H3indexCmpPhysicalFunction.hpp | 32 ++++++ .../Meos/H3indexEqPhysicalFunction.hpp | 32 ++++++ .../Meos/H3indexGePhysicalFunction.hpp | 32 ++++++ .../Meos/H3indexGtPhysicalFunction.hpp | 32 ++++++ .../Meos/H3indexLePhysicalFunction.hpp | 32 ++++++ .../Meos/H3indexLtPhysicalFunction.hpp | 32 ++++++ .../Meos/H3indexNePhysicalFunction.hpp | 32 ++++++ .../src/Functions/Meos/CMakeLists.txt | 7 ++ .../Meos/H3indexCmpPhysicalFunction.cpp | 67 +++++++++++++ .../Meos/H3indexEqPhysicalFunction.cpp | 68 +++++++++++++ .../Meos/H3indexGePhysicalFunction.cpp | 68 +++++++++++++ .../Meos/H3indexGtPhysicalFunction.cpp | 68 +++++++++++++ .../Meos/H3indexLePhysicalFunction.cpp | 68 +++++++++++++ .../Meos/H3indexLtPhysicalFunction.cpp | 68 +++++++++++++ .../Meos/H3indexNePhysicalFunction.cpp | 68 +++++++++++++ nes-sql-parser/AntlrSQL.g4 | 9 +- .../src/AntlrSQLQueryPlanCreator.cpp | 70 +++++++++++++ 32 files changed, 1820 insertions(+), 1 deletion(-) create mode 100644 nes-logical-operators/include/Functions/Meos/H3indexCmpLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/H3indexEqLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/H3indexGeLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/H3indexGtLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/H3indexLeLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/H3indexLtLogicalFunction.hpp create mode 100644 nes-logical-operators/include/Functions/Meos/H3indexNeLogicalFunction.hpp create mode 100644 nes-logical-operators/src/Functions/Meos/H3indexCmpLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/H3indexEqLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/H3indexGeLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/H3indexGtLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/H3indexLeLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/H3indexLtLogicalFunction.cpp create mode 100644 nes-logical-operators/src/Functions/Meos/H3indexNeLogicalFunction.cpp create mode 100644 nes-physical-operators/include/Functions/Meos/H3indexCmpPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/H3indexEqPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/H3indexGePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/H3indexGtPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/H3indexLePhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/H3indexLtPhysicalFunction.hpp create mode 100644 nes-physical-operators/include/Functions/Meos/H3indexNePhysicalFunction.hpp create mode 100644 nes-physical-operators/src/Functions/Meos/H3indexCmpPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/H3indexEqPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/H3indexGePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/H3indexGtPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/H3indexLePhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/H3indexLtPhysicalFunction.cpp create mode 100644 nes-physical-operators/src/Functions/Meos/H3indexNePhysicalFunction.cpp diff --git a/nes-logical-operators/include/Functions/Meos/H3indexCmpLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/H3indexCmpLogicalFunction.hpp new file mode 100644 index 0000000000..2e9785647c --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/H3indexCmpLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Returns -1, 0, or 1 comparison result for two H3 cell indices. + */ +class H3indexCmpLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "H3indexCmp"; + + H3indexCmpLogicalFunction(LogicalFunction a, LogicalFunction b); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/H3indexEqLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/H3indexEqLogicalFunction.hpp new file mode 100644 index 0000000000..9366a95735 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/H3indexEqLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests equality of two H3 cell indices. + */ +class H3indexEqLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "H3indexEq"; + + H3indexEqLogicalFunction(LogicalFunction a, LogicalFunction b); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/H3indexGeLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/H3indexGeLogicalFunction.hpp new file mode 100644 index 0000000000..70ed53efbd --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/H3indexGeLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests if H3 cell index a is greater than or equal to b. + */ +class H3indexGeLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "H3indexGe"; + + H3indexGeLogicalFunction(LogicalFunction a, LogicalFunction b); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/H3indexGtLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/H3indexGtLogicalFunction.hpp new file mode 100644 index 0000000000..cf4caadf39 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/H3indexGtLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests if H3 cell index a is greater than b. + */ +class H3indexGtLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "H3indexGt"; + + H3indexGtLogicalFunction(LogicalFunction a, LogicalFunction b); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/H3indexLeLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/H3indexLeLogicalFunction.hpp new file mode 100644 index 0000000000..e39658ad3e --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/H3indexLeLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests if H3 cell index a is less than or equal to b. + */ +class H3indexLeLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "H3indexLe"; + + H3indexLeLogicalFunction(LogicalFunction a, LogicalFunction b); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/H3indexLtLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/H3indexLtLogicalFunction.hpp new file mode 100644 index 0000000000..11faa7c622 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/H3indexLtLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests if H3 cell index a is less than b. + */ +class H3indexLtLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "H3indexLt"; + + H3indexLtLogicalFunction(LogicalFunction a, LogicalFunction b); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/include/Functions/Meos/H3indexNeLogicalFunction.hpp b/nes-logical-operators/include/Functions/Meos/H3indexNeLogicalFunction.hpp new file mode 100644 index 0000000000..3c60d6b995 --- /dev/null +++ b/nes-logical-operators/include/Functions/Meos/H3indexNeLogicalFunction.hpp @@ -0,0 +1,48 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +/** + * @brief Tests inequality of two H3 cell indices. + */ +class H3indexNeLogicalFunction : public LogicalFunctionConcept { +public: + static constexpr std::string_view NAME = "H3indexNe"; + + H3indexNeLogicalFunction(LogicalFunction a, LogicalFunction b); + + DataType getDataType() const override; + LogicalFunction withDataType(const DataType& dataType) const override; + std::vector getChildren() const override; + LogicalFunction withChildren(const std::vector& children) const override; + std::string_view getType() const override; + bool operator==(const LogicalFunctionConcept& rhs) const override; + std::string explain(ExplainVerbosity verbosity) const override; + LogicalFunction withInferredDataType(const Schema& schema) const override; + SerializableFunction serialize() const override; + +private: + DataType dataType; + std::vector parameters; +}; + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt index 8f922b7599..9e4b98d2e3 100644 --- a/nes-logical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-logical-operators/src/Functions/Meos/CMakeLists.txt @@ -493,6 +493,13 @@ add_plugin(AcontainsTgeoTgeo LogicalFunction nes-logical-operators AcontainsTgeo add_plugin(AtouchesTgeoTgeo LogicalFunction nes-logical-operators AtouchesTgeoTgeoLogicalFunction.cpp) add_plugin(EdwithinTgeoTgeo LogicalFunction nes-logical-operators EdwithinTgeoTgeoLogicalFunction.cpp) add_plugin(AdwithinTgeoTgeo LogicalFunction nes-logical-operators AdwithinTgeoTgeoLogicalFunction.cpp) +add_plugin(H3indexEq LogicalFunction nes-logical-operators H3indexEqLogicalFunction.cpp) +add_plugin(H3indexNe LogicalFunction nes-logical-operators H3indexNeLogicalFunction.cpp) +add_plugin(H3indexLt LogicalFunction nes-logical-operators H3indexLtLogicalFunction.cpp) +add_plugin(H3indexLe LogicalFunction nes-logical-operators H3indexLeLogicalFunction.cpp) +add_plugin(H3indexGt LogicalFunction nes-logical-operators H3indexGtLogicalFunction.cpp) +add_plugin(H3indexGe LogicalFunction nes-logical-operators H3indexGeLogicalFunction.cpp) +add_plugin(H3indexCmp LogicalFunction nes-logical-operators H3indexCmpLogicalFunction.cpp) add_plugin(GeomRelatePattern LogicalFunction nes-logical-operators GeomRelatePatternLogicalFunction.cpp) add_plugin(GeomIntersects2d LogicalFunction nes-logical-operators GeomIntersects2dLogicalFunction.cpp) add_plugin(GeomDwithin2d LogicalFunction nes-logical-operators GeomDwithin2dLogicalFunction.cpp) diff --git a/nes-logical-operators/src/Functions/Meos/H3indexCmpLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/H3indexCmpLogicalFunction.cpp new file mode 100644 index 0000000000..4a977150f7 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/H3indexCmpLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +H3indexCmpLogicalFunction::H3indexCmpLogicalFunction(LogicalFunction a, LogicalFunction b) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(a)); + parameters.push_back(std::move(b)); +} + +DataType H3indexCmpLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction H3indexCmpLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector H3indexCmpLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction H3indexCmpLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "H3indexCmpLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view H3indexCmpLogicalFunction::getType() const { return NAME; } + +bool H3indexCmpLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string H3indexCmpLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction H3indexCmpLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "a must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "b must be UINT64"); + return withChildren(c); +} + +SerializableFunction H3indexCmpLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterH3indexCmpLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "H3indexCmpLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return H3indexCmpLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/H3indexEqLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/H3indexEqLogicalFunction.cpp new file mode 100644 index 0000000000..95f6683a2c --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/H3indexEqLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +H3indexEqLogicalFunction::H3indexEqLogicalFunction(LogicalFunction a, LogicalFunction b) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(a)); + parameters.push_back(std::move(b)); +} + +DataType H3indexEqLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction H3indexEqLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector H3indexEqLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction H3indexEqLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "H3indexEqLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view H3indexEqLogicalFunction::getType() const { return NAME; } + +bool H3indexEqLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string H3indexEqLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction H3indexEqLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "a must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "b must be UINT64"); + return withChildren(c); +} + +SerializableFunction H3indexEqLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterH3indexEqLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "H3indexEqLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return H3indexEqLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/H3indexGeLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/H3indexGeLogicalFunction.cpp new file mode 100644 index 0000000000..66b18248f0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/H3indexGeLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +H3indexGeLogicalFunction::H3indexGeLogicalFunction(LogicalFunction a, LogicalFunction b) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(a)); + parameters.push_back(std::move(b)); +} + +DataType H3indexGeLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction H3indexGeLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector H3indexGeLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction H3indexGeLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "H3indexGeLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view H3indexGeLogicalFunction::getType() const { return NAME; } + +bool H3indexGeLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string H3indexGeLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction H3indexGeLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "a must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "b must be UINT64"); + return withChildren(c); +} + +SerializableFunction H3indexGeLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterH3indexGeLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "H3indexGeLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return H3indexGeLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/H3indexGtLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/H3indexGtLogicalFunction.cpp new file mode 100644 index 0000000000..02774e62c0 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/H3indexGtLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +H3indexGtLogicalFunction::H3indexGtLogicalFunction(LogicalFunction a, LogicalFunction b) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(a)); + parameters.push_back(std::move(b)); +} + +DataType H3indexGtLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction H3indexGtLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector H3indexGtLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction H3indexGtLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "H3indexGtLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view H3indexGtLogicalFunction::getType() const { return NAME; } + +bool H3indexGtLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string H3indexGtLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction H3indexGtLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "a must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "b must be UINT64"); + return withChildren(c); +} + +SerializableFunction H3indexGtLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterH3indexGtLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "H3indexGtLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return H3indexGtLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/H3indexLeLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/H3indexLeLogicalFunction.cpp new file mode 100644 index 0000000000..2116c829a9 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/H3indexLeLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +H3indexLeLogicalFunction::H3indexLeLogicalFunction(LogicalFunction a, LogicalFunction b) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(a)); + parameters.push_back(std::move(b)); +} + +DataType H3indexLeLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction H3indexLeLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector H3indexLeLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction H3indexLeLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "H3indexLeLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view H3indexLeLogicalFunction::getType() const { return NAME; } + +bool H3indexLeLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string H3indexLeLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction H3indexLeLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "a must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "b must be UINT64"); + return withChildren(c); +} + +SerializableFunction H3indexLeLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterH3indexLeLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "H3indexLeLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return H3indexLeLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/H3indexLtLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/H3indexLtLogicalFunction.cpp new file mode 100644 index 0000000000..330cad365b --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/H3indexLtLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +H3indexLtLogicalFunction::H3indexLtLogicalFunction(LogicalFunction a, LogicalFunction b) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(a)); + parameters.push_back(std::move(b)); +} + +DataType H3indexLtLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction H3indexLtLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector H3indexLtLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction H3indexLtLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "H3indexLtLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view H3indexLtLogicalFunction::getType() const { return NAME; } + +bool H3indexLtLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string H3indexLtLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction H3indexLtLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "a must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "b must be UINT64"); + return withChildren(c); +} + +SerializableFunction H3indexLtLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterH3indexLtLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "H3indexLtLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return H3indexLtLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-logical-operators/src/Functions/Meos/H3indexNeLogicalFunction.cpp b/nes-logical-operators/src/Functions/Meos/H3indexNeLogicalFunction.cpp new file mode 100644 index 0000000000..c22c3d2263 --- /dev/null +++ b/nes-logical-operators/src/Functions/Meos/H3indexNeLogicalFunction.cpp @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace NES +{ + +H3indexNeLogicalFunction::H3indexNeLogicalFunction(LogicalFunction a, LogicalFunction b) + : dataType(DataTypeProvider::provideDataType(DataType::Type::FLOAT64)) +{ + parameters.reserve(2); + parameters.push_back(std::move(a)); + parameters.push_back(std::move(b)); +} + +DataType H3indexNeLogicalFunction::getDataType() const { return dataType; } + +LogicalFunction H3indexNeLogicalFunction::withDataType(const DataType& newDataType) const +{ + auto copy = *this; copy.dataType = newDataType; return copy; +} + +std::vector H3indexNeLogicalFunction::getChildren() const { return parameters; } + +LogicalFunction H3indexNeLogicalFunction::withChildren(const std::vector& children) const +{ + PRECONDITION(children.size() == 2, + "H3indexNeLogicalFunction requires 2 children, but got {}", children.size()); + auto copy = *this; copy.parameters = children; return copy; +} + +std::string_view H3indexNeLogicalFunction::getType() const { return NAME; } + +bool H3indexNeLogicalFunction::operator==(const LogicalFunctionConcept& rhs) const +{ + if (const auto* other = dynamic_cast(&rhs)) + return parameters == other->parameters; + return false; +} + +std::string H3indexNeLogicalFunction::explain(ExplainVerbosity verbosity) const +{ + return fmt::format("{}({})", NAME, parameters[0].explain(verbosity)); +} + +LogicalFunction H3indexNeLogicalFunction::withInferredDataType(const Schema& schema) const +{ + std::vector c; + c.reserve(2); + for (const auto& p : parameters) + c.emplace_back(p.withInferredDataType(schema)); + INVARIANT(c[0].getDataType().isType(DataType::Type::UINT64), "a must be UINT64"); + INVARIANT(c[1].getDataType().isType(DataType::Type::UINT64), "b must be UINT64"); + return withChildren(c); +} + +SerializableFunction H3indexNeLogicalFunction::serialize() const +{ + SerializableFunction proto; + proto.set_function_type(std::string(NAME)); + DataTypeSerializationUtil::serializeDataType(dataType, proto.mutable_data_type()); + for (const auto& child : parameters) + proto.add_children()->CopyFrom(child.serialize()); + return proto; +} + +LogicalFunctionRegistryReturnType LogicalFunctionGeneratedRegistrar::RegisterH3indexNeLogicalFunction( + LogicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.children.size() == 2, + "H3indexNeLogicalFunction requires 2 children but got {}", + arguments.children.size()); + return H3indexNeLogicalFunction( + std::move(arguments.children[0]), + std::move(arguments.children[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/H3indexCmpPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/H3indexCmpPhysicalFunction.hpp new file mode 100644 index 0000000000..5c8febc7a3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/H3indexCmpPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class H3indexCmpPhysicalFunction : public PhysicalFunctionConcept { +public: + H3indexCmpPhysicalFunction(PhysicalFunction a, PhysicalFunction b); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/H3indexEqPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/H3indexEqPhysicalFunction.hpp new file mode 100644 index 0000000000..7dc9cacf8a --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/H3indexEqPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class H3indexEqPhysicalFunction : public PhysicalFunctionConcept { +public: + H3indexEqPhysicalFunction(PhysicalFunction a, PhysicalFunction b); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/H3indexGePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/H3indexGePhysicalFunction.hpp new file mode 100644 index 0000000000..ebcaf7dcac --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/H3indexGePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class H3indexGePhysicalFunction : public PhysicalFunctionConcept { +public: + H3indexGePhysicalFunction(PhysicalFunction a, PhysicalFunction b); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/H3indexGtPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/H3indexGtPhysicalFunction.hpp new file mode 100644 index 0000000000..50bf965ca3 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/H3indexGtPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class H3indexGtPhysicalFunction : public PhysicalFunctionConcept { +public: + H3indexGtPhysicalFunction(PhysicalFunction a, PhysicalFunction b); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/H3indexLePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/H3indexLePhysicalFunction.hpp new file mode 100644 index 0000000000..d08a506963 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/H3indexLePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class H3indexLePhysicalFunction : public PhysicalFunctionConcept { +public: + H3indexLePhysicalFunction(PhysicalFunction a, PhysicalFunction b); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/H3indexLtPhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/H3indexLtPhysicalFunction.hpp new file mode 100644 index 0000000000..6e58dce8f0 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/H3indexLtPhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class H3indexLtPhysicalFunction : public PhysicalFunctionConcept { +public: + H3indexLtPhysicalFunction(PhysicalFunction a, PhysicalFunction b); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/include/Functions/Meos/H3indexNePhysicalFunction.hpp b/nes-physical-operators/include/Functions/Meos/H3indexNePhysicalFunction.hpp new file mode 100644 index 0000000000..3065e3e410 --- /dev/null +++ b/nes-physical-operators/include/Functions/Meos/H3indexNePhysicalFunction.hpp @@ -0,0 +1,32 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include +#include +#include +#include + +namespace NES { + +class H3indexNePhysicalFunction : public PhysicalFunctionConcept { +public: + H3indexNePhysicalFunction(PhysicalFunction a, PhysicalFunction b); + VarVal execute(const Record& record, ArenaRef& arena) const override; +private: + std::vector paramFns; +}; + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt index 49ed24d7dd..76515d0644 100644 --- a/nes-physical-operators/src/Functions/Meos/CMakeLists.txt +++ b/nes-physical-operators/src/Functions/Meos/CMakeLists.txt @@ -492,6 +492,13 @@ add_plugin(AcontainsTgeoTgeo PhysicalFunction nes-physical-operators AcontainsTg add_plugin(AtouchesTgeoTgeo PhysicalFunction nes-physical-operators AtouchesTgeoTgeoPhysicalFunction.cpp) add_plugin(EdwithinTgeoTgeo PhysicalFunction nes-physical-operators EdwithinTgeoTgeoPhysicalFunction.cpp) add_plugin(AdwithinTgeoTgeo PhysicalFunction nes-physical-operators AdwithinTgeoTgeoPhysicalFunction.cpp) +add_plugin(H3indexEq PhysicalFunction nes-physical-operators H3indexEqPhysicalFunction.cpp) +add_plugin(H3indexNe PhysicalFunction nes-physical-operators H3indexNePhysicalFunction.cpp) +add_plugin(H3indexLt PhysicalFunction nes-physical-operators H3indexLtPhysicalFunction.cpp) +add_plugin(H3indexLe PhysicalFunction nes-physical-operators H3indexLePhysicalFunction.cpp) +add_plugin(H3indexGt PhysicalFunction nes-physical-operators H3indexGtPhysicalFunction.cpp) +add_plugin(H3indexGe PhysicalFunction nes-physical-operators H3indexGePhysicalFunction.cpp) +add_plugin(H3indexCmp PhysicalFunction nes-physical-operators H3indexCmpPhysicalFunction.cpp) add_plugin(GeomRelatePattern PhysicalFunction nes-physical-operators GeomRelatePatternPhysicalFunction.cpp) add_plugin(GeomIntersects2d PhysicalFunction nes-physical-operators GeomIntersects2dPhysicalFunction.cpp) add_plugin(GeomDwithin2d PhysicalFunction nes-physical-operators GeomDwithin2dPhysicalFunction.cpp) diff --git a/nes-physical-operators/src/Functions/Meos/H3indexCmpPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/H3indexCmpPhysicalFunction.cpp new file mode 100644 index 0000000000..13a6b9d241 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/H3indexCmpPhysicalFunction.cpp @@ -0,0 +1,67 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +H3indexCmpPhysicalFunction::H3indexCmpPhysicalFunction(PhysicalFunction a, PhysicalFunction b) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(a)); + paramFns.push_back(std::move(b)); +} + +VarVal H3indexCmpPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto a = paramFns[0].execute(record, arena).cast(); + auto b = paramFns[1].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t a, uint64_t b) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + return (double)h3index_cmp((H3Index)a, (H3Index)b); + } catch (const std::exception&) { return 0.0; } + }, + a, b); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterH3indexCmpPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "H3indexCmpPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return H3indexCmpPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/H3indexEqPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/H3indexEqPhysicalFunction.cpp new file mode 100644 index 0000000000..ad35230f13 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/H3indexEqPhysicalFunction.cpp @@ -0,0 +1,68 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +H3indexEqPhysicalFunction::H3indexEqPhysicalFunction(PhysicalFunction a, PhysicalFunction b) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(a)); + paramFns.push_back(std::move(b)); +} + +VarVal H3indexEqPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto a = paramFns[0].execute(record, arena).cast(); + auto b = paramFns[1].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t a, uint64_t b) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + bool r = h3index_eq((H3Index)a, (H3Index)b); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + a, b); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterH3indexEqPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "H3indexEqPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return H3indexEqPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/H3indexGePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/H3indexGePhysicalFunction.cpp new file mode 100644 index 0000000000..2a3e75abac --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/H3indexGePhysicalFunction.cpp @@ -0,0 +1,68 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +H3indexGePhysicalFunction::H3indexGePhysicalFunction(PhysicalFunction a, PhysicalFunction b) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(a)); + paramFns.push_back(std::move(b)); +} + +VarVal H3indexGePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto a = paramFns[0].execute(record, arena).cast(); + auto b = paramFns[1].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t a, uint64_t b) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + bool r = h3index_ge((H3Index)a, (H3Index)b); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + a, b); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterH3indexGePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "H3indexGePhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return H3indexGePhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/H3indexGtPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/H3indexGtPhysicalFunction.cpp new file mode 100644 index 0000000000..c7125d6c48 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/H3indexGtPhysicalFunction.cpp @@ -0,0 +1,68 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +H3indexGtPhysicalFunction::H3indexGtPhysicalFunction(PhysicalFunction a, PhysicalFunction b) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(a)); + paramFns.push_back(std::move(b)); +} + +VarVal H3indexGtPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto a = paramFns[0].execute(record, arena).cast(); + auto b = paramFns[1].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t a, uint64_t b) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + bool r = h3index_gt((H3Index)a, (H3Index)b); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + a, b); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterH3indexGtPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "H3indexGtPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return H3indexGtPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/H3indexLePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/H3indexLePhysicalFunction.cpp new file mode 100644 index 0000000000..36cc8f4658 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/H3indexLePhysicalFunction.cpp @@ -0,0 +1,68 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +H3indexLePhysicalFunction::H3indexLePhysicalFunction(PhysicalFunction a, PhysicalFunction b) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(a)); + paramFns.push_back(std::move(b)); +} + +VarVal H3indexLePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto a = paramFns[0].execute(record, arena).cast(); + auto b = paramFns[1].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t a, uint64_t b) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + bool r = h3index_le((H3Index)a, (H3Index)b); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + a, b); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterH3indexLePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "H3indexLePhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return H3indexLePhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/H3indexLtPhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/H3indexLtPhysicalFunction.cpp new file mode 100644 index 0000000000..b7d302be73 --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/H3indexLtPhysicalFunction.cpp @@ -0,0 +1,68 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +H3indexLtPhysicalFunction::H3indexLtPhysicalFunction(PhysicalFunction a, PhysicalFunction b) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(a)); + paramFns.push_back(std::move(b)); +} + +VarVal H3indexLtPhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto a = paramFns[0].execute(record, arena).cast(); + auto b = paramFns[1].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t a, uint64_t b) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + bool r = h3index_lt((H3Index)a, (H3Index)b); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + a, b); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterH3indexLtPhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "H3indexLtPhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return H3indexLtPhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-physical-operators/src/Functions/Meos/H3indexNePhysicalFunction.cpp b/nes-physical-operators/src/Functions/Meos/H3indexNePhysicalFunction.cpp new file mode 100644 index 0000000000..10b3891b6e --- /dev/null +++ b/nes-physical-operators/src/Functions/Meos/H3indexNePhysicalFunction.cpp @@ -0,0 +1,68 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} + +namespace NES { + +H3indexNePhysicalFunction::H3indexNePhysicalFunction(PhysicalFunction a, PhysicalFunction b) +{ + paramFns.reserve(2); + paramFns.push_back(std::move(a)); + paramFns.push_back(std::move(b)); +} + +VarVal H3indexNePhysicalFunction::execute(const Record& record, ArenaRef& arena) const +{ + auto a = paramFns[0].execute(record, arena).cast(); + auto b = paramFns[1].execute(record, arena).cast(); + const auto result = nautilus::invoke( + +[](uint64_t a, uint64_t b) -> double { + try { + MEOS::Meos::ensureMeosInitialized(); + bool r = h3index_ne((H3Index)a, (H3Index)b); + return r ? 1.0 : 0.0; + } catch (const std::exception&) { return 0.0; } + }, + a, b); + return VarVal(result); +} + +PhysicalFunctionRegistryReturnType PhysicalFunctionGeneratedRegistrar::RegisterH3indexNePhysicalFunction( + PhysicalFunctionRegistryArguments arguments) +{ + PRECONDITION(arguments.childFunctions.size() == 2, + "H3indexNePhysicalFunction requires 2 children but got {}", + arguments.childFunctions.size()); + return H3indexNePhysicalFunction( + std::move(arguments.childFunctions[0]), + std::move(arguments.childFunctions[1])); +} + +} // namespace NES diff --git a/nes-sql-parser/AntlrSQL.g4 b/nes-sql-parser/AntlrSQL.g4 index 0e6b471cba..06fcd39779 100644 --- a/nes-sql-parser/AntlrSQL.g4 +++ b/nes-sql-parser/AntlrSQL.g4 @@ -295,7 +295,7 @@ timeUnit: MS timestampParameter: name=identifier; -functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_POINT_MAKE2D | GEOM_POINT_MAKE3DZ | GEOG_POINT_MAKE2D | GEOG_POINT_MAKE3DZ | GEOM_TO_GEOG | GEOG_TO_GEOM | GEOG_CENTROID | GEO_GEO_N | LINE_POINT_N | GEOM_INTERSECTION2D_COLL | GEO_AS_GEOJSON | GEO_AS_HEXEWKB | GEO_AS_EWKT | GEO_FROM_GEOJSON | GEOM_FROM_HEXEWKB | GEO_TRANSFORM_PIPELINE | GEOM_MIN_BOUNDING_CENTER | GEOM_MIN_BOUNDING_RADIUS | EVER_EQ_TGEO_TGEO | EVER_NE_TGEO_TGEO | ALWAYS_EQ_TGEO_TGEO | ALWAYS_NE_TGEO_TGEO | EINTERSECTS_TGEO_TGEO | ECOVERS_TGEO_TGEO | EDISJOINT_TGEO_TGEO | ECONTAINS_TGEO_TGEO | ETOUCHES_TGEO_TGEO | AINTERSECTS_TGEO_TGEO | ACOVERS_TGEO_TGEO | ADISJOINT_TGEO_TGEO | ACONTAINS_TGEO_TGEO | ATOUCHES_TGEO_TGEO | EDWITHIN_TGEO_TGEO | ADWITHIN_TGEO_TGEO | GEOM_RELATE_PATTERN | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; +functionName: IDENTIFIER | AVG | MAX | MIN | SUM | COUNT | MEDIAN | ARRAY_AGG | VAR | TEMPORAL_SEQUENCE | TEMPORAL_EINTERSECTS_GEOMETRY | TEMPORAL_AINTERSECTS_GEOMETRY | TEMPORAL_ECONTAINS_GEOMETRY | ALWAYS_EQ_BIGINT_TBIGINT | ALWAYS_GE_BIGINT_TBIGINT | ALWAYS_GT_BIGINT_TBIGINT | ALWAYS_LE_BIGINT_TBIGINT | ALWAYS_LT_BIGINT_TBIGINT | ALWAYS_NE_BIGINT_TBIGINT | ALWAYS_EQ_TBIGINT_BIGINT | ALWAYS_GE_TBIGINT_BIGINT | ALWAYS_GT_TBIGINT_BIGINT | ALWAYS_LE_TBIGINT_BIGINT | ALWAYS_LT_TBIGINT_BIGINT | ALWAYS_NE_TBIGINT_BIGINT | ALWAYS_EQ_TBIGINT_TBIGINT | ALWAYS_GE_TBIGINT_TBIGINT | ALWAYS_GT_TBIGINT_TBIGINT | ALWAYS_LE_TBIGINT_TBIGINT | ALWAYS_LT_TBIGINT_TBIGINT | ALWAYS_NE_TBIGINT_TBIGINT | ALWAYS_EQ_BOOL_TBOOL | ALWAYS_NE_BOOL_TBOOL | ALWAYS_EQ_FLOAT_TFLOAT | ALWAYS_GE_FLOAT_TFLOAT | ALWAYS_GT_FLOAT_TFLOAT | ALWAYS_LE_FLOAT_TFLOAT | ALWAYS_LT_FLOAT_TFLOAT | ALWAYS_NE_FLOAT_TFLOAT | ALWAYS_EQ_TBOOL_BOOL | ALWAYS_NE_TBOOL_BOOL | ALWAYS_EQ_TEMPORAL_TEMPORAL | ALWAYS_GE_TEMPORAL_TEMPORAL | ALWAYS_GT_TEMPORAL_TEMPORAL | ALWAYS_LE_TEMPORAL_TEMPORAL | ALWAYS_LT_TEMPORAL_TEMPORAL | ALWAYS_NE_TEMPORAL_TEMPORAL | ALWAYS_EQ_TFLOAT_FLOAT | ALWAYS_GE_TFLOAT_FLOAT | ALWAYS_GT_TFLOAT_FLOAT | ALWAYS_LE_TFLOAT_FLOAT | ALWAYS_LT_TFLOAT_FLOAT | ALWAYS_NE_TFLOAT_FLOAT | ALWAYS_EQ_TFLOAT_TFLOAT | ALWAYS_GE_TFLOAT_TFLOAT | ALWAYS_GT_TFLOAT_TFLOAT | ALWAYS_LE_TFLOAT_TFLOAT | ALWAYS_LT_TFLOAT_TFLOAT | ALWAYS_NE_TFLOAT_TFLOAT | ALWAYS_EQ_INT_TINT | ALWAYS_GE_INT_TINT | ALWAYS_GT_INT_TINT | ALWAYS_LE_INT_TINT | ALWAYS_LT_INT_TINT | ALWAYS_NE_INT_TINT | ALWAYS_EQ_TINT_INT | ALWAYS_GE_TINT_INT | ALWAYS_GT_TINT_INT | ALWAYS_LE_TINT_INT | ALWAYS_LT_TINT_INT | ALWAYS_NE_TINT_INT | ALWAYS_EQ_TINT_TINT | ALWAYS_GE_TINT_TINT | ALWAYS_GT_TINT_TINT | ALWAYS_LE_TINT_TINT | ALWAYS_LT_TINT_TINT | ALWAYS_NE_TINT_TINT | EDWITHIN_TGEO_GEO | EVER_EQ_BIGINT_TBIGINT | EVER_GE_BIGINT_TBIGINT | EVER_GT_BIGINT_TBIGINT | EVER_LE_BIGINT_TBIGINT | EVER_LT_BIGINT_TBIGINT | EVER_NE_BIGINT_TBIGINT | EVER_EQ_TBIGINT_BIGINT | EVER_GE_TBIGINT_BIGINT | EVER_GT_TBIGINT_BIGINT | EVER_LE_TBIGINT_BIGINT | EVER_LT_TBIGINT_BIGINT | EVER_NE_TBIGINT_BIGINT | EVER_EQ_TBIGINT_TBIGINT | EVER_GE_TBIGINT_TBIGINT | EVER_GT_TBIGINT_TBIGINT | EVER_LE_TBIGINT_TBIGINT | EVER_LT_TBIGINT_TBIGINT | EVER_NE_TBIGINT_TBIGINT | EVER_EQ_BOOL_TBOOL | EVER_NE_BOOL_TBOOL | EVER_EQ_FLOAT_TFLOAT | EVER_GE_FLOAT_TFLOAT | EVER_GT_FLOAT_TFLOAT | EVER_LE_FLOAT_TFLOAT | EVER_LT_FLOAT_TFLOAT | EVER_NE_FLOAT_TFLOAT | EVER_EQ_TBOOL_BOOL | EVER_NE_TBOOL_BOOL | EVER_EQ_TEMPORAL_TEMPORAL | EVER_GE_TEMPORAL_TEMPORAL | EVER_GT_TEMPORAL_TEMPORAL | EVER_LE_TEMPORAL_TEMPORAL | EVER_LT_TEMPORAL_TEMPORAL | EVER_NE_TEMPORAL_TEMPORAL | EVER_EQ_TFLOAT_FLOAT | EVER_GE_TFLOAT_FLOAT | EVER_GT_TFLOAT_FLOAT | EVER_LE_TFLOAT_FLOAT | EVER_LT_TFLOAT_FLOAT | EVER_NE_TFLOAT_FLOAT | EVER_EQ_TFLOAT_TFLOAT | EVER_GE_TFLOAT_TFLOAT | EVER_GT_TFLOAT_TFLOAT | EVER_LE_TFLOAT_TFLOAT | EVER_LT_TFLOAT_TFLOAT | EVER_NE_TFLOAT_TFLOAT | EVER_EQ_INT_TINT | EVER_GE_INT_TINT | EVER_GT_INT_TINT | EVER_LE_INT_TINT | EVER_LT_INT_TINT | EVER_NE_INT_TINT | EVER_EQ_TINT_INT | EVER_GE_TINT_INT | EVER_GT_TINT_INT | EVER_LE_TINT_INT | EVER_LT_TINT_INT | EVER_NE_TINT_INT | EVER_EQ_TINT_TINT | EVER_GE_TINT_TINT | EVER_GT_TINT_TINT | EVER_LE_TINT_TINT | EVER_LT_TINT_TINT | EVER_NE_TINT_TINT | TGEO_AT_STBOX | ADD_BIGINT_TBIGINT | ADD_FLOAT_TFLOAT | ADD_INT_TINT | ADD_TBIGINT_BIGINT | ADD_TFLOAT_FLOAT | ADD_TINT_INT | ADD_TNUMBER_TNUMBER | DIV_BIGINT_TBIGINT | DIV_FLOAT_TFLOAT | DIV_INT_TINT | DIV_TBIGINT_BIGINT | DIV_TFLOAT_FLOAT | DIV_TINT_INT | DIV_TNUMBER_TNUMBER | MUL_BIGINT_TBIGINT | MUL_FLOAT_TFLOAT | MUL_INT_TINT | MUL_TBIGINT_BIGINT | MUL_TFLOAT_FLOAT | MUL_TINT_INT | MUL_TNUMBER_TNUMBER | SUB_BIGINT_TBIGINT | SUB_FLOAT_TFLOAT | SUB_INT_TINT | SUB_TBIGINT_BIGINT | SUB_TFLOAT_FLOAT | SUB_TINT_INT | SUB_TNUMBER_TNUMBER | TDISTANCE_TFLOAT_FLOAT | TDISTANCE_TINT_INT | TDISTANCE_TNUMBER_TNUMBER | TEMPORAL_ROUND | TFLOAT_CEIL | TFLOAT_COS | TFLOAT_DEGREES | TFLOAT_EXP | TFLOAT_FLOOR | TFLOAT_LN | TFLOAT_LOG10 | TFLOAT_RADIANS | TFLOAT_SCALE_VALUE | TFLOAT_SHIFT_SCALE_VALUE | TBIGINT_SCALE_VALUE | TBIGINT_SHIFT_SCALE_VALUE | TBIGINT_SHIFT_VALUE | TBIGINT_TO_TFLOAT | TBIGINT_TO_TINT | TFLOAT_SHIFT_VALUE | TFLOAT_SIN | TFLOAT_TAN | TFLOAT_TO_TBIGINT | TFLOAT_TO_TINT | TINT_SCALE_VALUE | TINT_SHIFT_SCALE_VALUE | TINT_SHIFT_VALUE | TINT_TO_TBIGINT | TINT_TO_TFLOAT | TNUMBER_ABS | TAND_BOOL_TBOOL | TAND_TBOOL_BOOL | TAND_TBOOL_TBOOL | TNOT_TBOOL | TOR_BOOL_TBOOL | TOR_TBOOL_BOOL | TOR_TBOOL_TBOOL | TEQ_BOOL_TBOOL | TEQ_FLOAT_TFLOAT | TEQ_INT_TINT | TEQ_TBOOL_BOOL | TEQ_TEMPORAL_TEMPORAL | TEQ_TFLOAT_FLOAT | TEQ_TINT_INT | TNE_TBOOL_BOOL | TNE_BOOL_TBOOL | TNE_TFLOAT_FLOAT | TNE_FLOAT_TFLOAT | TNE_TINT_INT | TNE_INT_TINT | TNE_TEMPORAL_TEMPORAL | TGE_TFLOAT_FLOAT | TGE_FLOAT_TFLOAT | TGE_TINT_INT | TGE_INT_TINT | TGE_TEMPORAL_TEMPORAL | TGT_TFLOAT_FLOAT | TGT_FLOAT_TFLOAT | TGT_TINT_INT | TGT_INT_TINT | TGT_TEMPORAL_TEMPORAL | TLE_TFLOAT_FLOAT | TLE_FLOAT_TFLOAT | TLE_TINT_INT | TLE_INT_TINT | TLE_TEMPORAL_TEMPORAL | TLT_TFLOAT_FLOAT | TLT_FLOAT_TFLOAT | TLT_TINT_INT | TLT_INT_TINT | TLT_TEMPORAL_TEMPORAL | TBOOL_TO_TINT | EVER_EQ_TTEXT_TEXT | EVER_NE_TTEXT_TEXT | EVER_GE_TTEXT_TEXT | EVER_GT_TTEXT_TEXT | EVER_LE_TTEXT_TEXT | EVER_LT_TTEXT_TEXT | EVER_EQ_TEXT_TTEXT | EVER_NE_TEXT_TTEXT | EVER_GE_TEXT_TTEXT | EVER_GT_TEXT_TTEXT | EVER_LE_TEXT_TTEXT | EVER_LT_TEXT_TTEXT | ALWAYS_EQ_TTEXT_TEXT | ALWAYS_NE_TTEXT_TEXT | ALWAYS_GE_TTEXT_TEXT | ALWAYS_GT_TTEXT_TEXT | ALWAYS_LE_TTEXT_TEXT | ALWAYS_LT_TTEXT_TEXT | ALWAYS_EQ_TEXT_TTEXT | ALWAYS_NE_TEXT_TTEXT | ALWAYS_GE_TEXT_TTEXT | ALWAYS_GT_TEXT_TTEXT | ALWAYS_LE_TEXT_TTEXT | ALWAYS_LT_TEXT_TTEXT | TEQ_TTEXT_TEXT | TNE_TTEXT_TEXT | TEQ_TEXT_TTEXT | TNE_TEXT_TTEXT | TGE_TTEXT_TEXT | TGE_TEXT_TTEXT | TGT_TTEXT_TEXT | TGT_TEXT_TTEXT | TLE_TTEXT_TEXT | TLE_TEXT_TTEXT | TLT_TTEXT_TEXT | TLT_TEXT_TTEXT | TTEXT_UPPER | TTEXT_LOWER | TTEXT_INITCAP | TEXTCAT_TTEXT_TEXT | TEXTCAT_TEXT_TTEXT | TEXTCAT_TTEXT_TTEXT | GEOM_LENGTH | GEOM_PERIMETER | GEOM_AZIMUTH | GEOG_AREA | GEOG_LENGTH | GEOG_PERIMETER | GEOM_IS_EMPTY | AINTERSECTS_TGEO_GEO | ACOVERS_TGEO_GEO | ADISJOINT_TGEO_GEO | ADWITHIN_TGEO_GEO | EINTERSECTS_TGEO_GEO | ETOUCHES_TGEO_GEO | ECONTAINS_TGEO_GEO | ACONTAINS_TGEO_GEO | ATOUCHES_TGEO_GEO | GEO_NUM_POINTS | GEO_NUM_GEOS | GEO_SRID | GEO_IS_UNITARY | GEO_EQUALS | GEO_SAME | GEOG_DISTANCE | NAD_TGEO_GEO | EVER_EQ_TGEO_GEO | EVER_NE_TGEO_GEO | ALWAYS_EQ_TGEO_GEO | ALWAYS_NE_TGEO_GEO | GEOG_INTERSECTS | GEOG_DWITHIN | ACOVERS_GEO_TGEO | GEOM_INTERSECTS | GEOM_DWITHIN | H3_GS_POINT_TO_CELL | EVER_EQ_TH3INDEX_H3INDEX | EVER_NE_TH3INDEX_H3INDEX | ALWAYS_EQ_TH3INDEX_H3INDEX | ALWAYS_NE_TH3INDEX_H3INDEX | TH3INDEX_GET_RESOLUTION | TH3INDEX_GET_BASE_CELL_NUMBER | TH3INDEX_IS_VALID_CELL | TH3INDEX_IS_PENTAGON | TH3INDEX_CELL_TO_PARENT_NEXT | TH3INDEX_CELL_TO_CENTER_CHILD_NEXT | TH3INDEX_CELL_TO_PARENT | TH3INDEX_CELL_TO_CENTER_CHILD | TH3INDEX_CELL_TO_CHILD_POS | TH3INDEX_ARE_NEIGHBOR_CELLS | TH3INDEX_GRID_DISTANCE | EINTERSECTS_TCBUFFER_GEO | AINTERSECTS_TCBUFFER_GEO | ECOVERS_TCBUFFER_GEO | ACOVERS_TCBUFFER_GEO | EDISJOINT_TCBUFFER_GEO | ADISJOINT_TCBUFFER_GEO | ETOUCHES_TCBUFFER_GEO | ATOUCHES_TCBUFFER_GEO | ECONTAINS_TCBUFFER_GEO | ACONTAINS_TCBUFFER_GEO | NAD_TCBUFFER_GEO | EDWITHIN_TCBUFFER_GEO | ADWITHIN_TCBUFFER_GEO | EINTERSECTS_TCBUFFER_CBUFFER | AINTERSECTS_TCBUFFER_CBUFFER | ECOVERS_TCBUFFER_CBUFFER | ACOVERS_TCBUFFER_CBUFFER | EDISJOINT_TCBUFFER_CBUFFER | ADISJOINT_TCBUFFER_CBUFFER | ETOUCHES_TCBUFFER_CBUFFER | ATOUCHES_TCBUFFER_CBUFFER | ECONTAINS_TCBUFFER_CBUFFER | ACONTAINS_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_CBUFFER | ALWAYS_EQ_TCBUFFER_CBUFFER | EVER_NE_TCBUFFER_CBUFFER | ALWAYS_NE_TCBUFFER_CBUFFER | NAD_TCBUFFER_CBUFFER | EVER_EQ_TCBUFFER_TCBUFFER | ALWAYS_EQ_TCBUFFER_TCBUFFER | EVER_NE_TCBUFFER_TCBUFFER | ALWAYS_NE_TCBUFFER_TCBUFFER | EINTERSECTS_TCBUFFER_TCBUFFER | AINTERSECTS_TCBUFFER_TCBUFFER | ECOVERS_TCBUFFER_TCBUFFER | ACOVERS_TCBUFFER_TCBUFFER | ADISJOINT_TCBUFFER_TCBUFFER | ETOUCHES_TCBUFFER_TCBUFFER | ATOUCHES_TCBUFFER_TCBUFFER | NAD_TCBUFFER_TCBUFFER | EDWITHIN_TCBUFFER_TCBUFFER | ADWITHIN_TCBUFFER_TCBUFFER | MINDISTANCE_TCBUFFER_TCBUFFER | NAD_TNPOINT_GEO | EVER_EQ_TNPOINT_NPOINT | ALWAYS_EQ_TNPOINT_NPOINT | EVER_NE_TNPOINT_NPOINT | ALWAYS_NE_TNPOINT_NPOINT | NAD_TNPOINT_NPOINT | EVER_EQ_NPOINT_TNPOINT | ALWAYS_EQ_NPOINT_TNPOINT | EVER_NE_NPOINT_TNPOINT | ALWAYS_NE_NPOINT_TNPOINT | EVER_EQ_TNPOINT_TNPOINT | ALWAYS_EQ_TNPOINT_TNPOINT | EVER_NE_TNPOINT_TNPOINT | ALWAYS_NE_TNPOINT_TNPOINT | NAD_TNPOINT_TNPOINT | NAD_TPOSE_GEO | EVER_EQ_TPOSE_POSE | ALWAYS_EQ_TPOSE_POSE | EVER_NE_TPOSE_POSE | ALWAYS_NE_TPOSE_POSE | NAD_TPOSE_POSE | EVER_EQ_POSE_TPOSE | ALWAYS_EQ_POSE_TPOSE | EVER_NE_POSE_TPOSE | ALWAYS_NE_POSE_TPOSE | EVER_EQ_TPOSE_TPOSE | ALWAYS_EQ_TPOSE_TPOSE | EVER_NE_TPOSE_TPOSE | ALWAYS_NE_TPOSE_TPOSE | NAD_TPOSE_TPOSE | EVER_EQ_TRGEOMETRY_GEO | ALWAYS_EQ_TRGEOMETRY_GEO | EVER_NE_TRGEOMETRY_GEO | ALWAYS_NE_TRGEOMETRY_GEO | NAD_TRGEOMETRY_GEO | EVER_EQ_GEO_TRGEOMETRY | ALWAYS_EQ_GEO_TRGEOMETRY | EVER_NE_GEO_TRGEOMETRY | ALWAYS_NE_GEO_TRGEOMETRY | EVER_EQ_TRGEOMETRY_TRGEOMETRY | ALWAYS_EQ_TRGEOMETRY_TRGEOMETRY | EVER_NE_TRGEOMETRY_TRGEOMETRY | ALWAYS_NE_TRGEOMETRY_TRGEOMETRY | NAD_TRGEOMETRY_TRGEOMETRY | EINTERSECTS_TPCPOINT_GEO | NAD_TPCPOINT_GEO | QUADBIN_POINT_TO_CELL | QUADBIN_IS_VALID_CELL | QUADBIN_GET_RESOLUTION | QUADBIN_CELL_AREA | QUADBIN_CELL_TO_QUADKEY | QUADBIN_CELL_TO_PARENT | QUADBIN_TILE_TO_CELL | EVER_EQ_TJSONB_JSONB | ALWAYS_EQ_TJSONB_JSONB | EVER_NE_TJSONB_JSONB | ALWAYS_NE_TJSONB_JSONB | EVER_EQ_TJSONB_TJSONB | ALWAYS_EQ_TJSONB_TJSONB | EVER_NE_TJSONB_TJSONB | ALWAYS_NE_TJSONB_TJSONB | GEOM_BOUNDARY | GEOM_CENTROID | GEOM_CONVEX_HULL | GEO_REVERSE | GEO_POINTS | GEOM_UNARY_UNION | GEOM_DIFFERENCE2D | GEOM_INTERSECTION2D | GEOM_SHORTESTLINE2D | GEOM_SHORTESTLINE3D | GEO_SET_SRID | GEO_TRANSFORM | GEO_ROUND | GEOM_BUFFER | LINE_NUMPOINTS | LINE_LOCATE_POINT | LINE_INTERPOLATE_POINT | LINE_SUBSTRING | GEOM_POINT_MAKE2D | GEOM_POINT_MAKE3DZ | GEOG_POINT_MAKE2D | GEOG_POINT_MAKE3DZ | GEOM_TO_GEOG | GEOG_TO_GEOM | GEOG_CENTROID | GEO_GEO_N | LINE_POINT_N | GEOM_INTERSECTION2D_COLL | GEO_AS_GEOJSON | GEO_AS_HEXEWKB | GEO_AS_EWKT | GEO_FROM_GEOJSON | GEOM_FROM_HEXEWKB | GEO_TRANSFORM_PIPELINE | GEOM_MIN_BOUNDING_CENTER | GEOM_MIN_BOUNDING_RADIUS | EVER_EQ_TGEO_TGEO | EVER_NE_TGEO_TGEO | ALWAYS_EQ_TGEO_TGEO | ALWAYS_NE_TGEO_TGEO | EINTERSECTS_TGEO_TGEO | ECOVERS_TGEO_TGEO | EDISJOINT_TGEO_TGEO | ECONTAINS_TGEO_TGEO | ETOUCHES_TGEO_TGEO | AINTERSECTS_TGEO_TGEO | ACOVERS_TGEO_TGEO | ADISJOINT_TGEO_TGEO | ACONTAINS_TGEO_TGEO | ATOUCHES_TGEO_TGEO | EDWITHIN_TGEO_TGEO | ADWITHIN_TGEO_TGEO | H3INDEX_EQ | H3INDEX_NE | H3INDEX_LT | H3INDEX_LE | H3INDEX_GT | H3INDEX_GE | H3INDEX_CMP | GEOM_RELATE_PATTERN | GEOM_INTERSECTS2D | GEOM_DWITHIN2D | GEOM_CONTAINS | GEOM_DISJOINT2D | GEOM_COVERS | GEOM_TOUCHES | GEOM_INTERSECTS3D | GEOM_DWITHIN3D | GEOM_DISTANCE2D | GEOM_DISTANCE3D; sinkClause: INTO sink (',' sink)*; @@ -963,6 +963,13 @@ ACONTAINS_TGEO_TGEO: 'ACONTAINS_TGEO_TGEO' | 'acontains_tgeo_tgeo'; ATOUCHES_TGEO_TGEO: 'ATOUCHES_TGEO_TGEO' | 'atouches_tgeo_tgeo'; EDWITHIN_TGEO_TGEO: 'EDWITHIN_TGEO_TGEO' | 'edwithin_tgeo_tgeo'; ADWITHIN_TGEO_TGEO: 'ADWITHIN_TGEO_TGEO' | 'adwithin_tgeo_tgeo'; +H3INDEX_EQ: 'H3INDEX_EQ' | 'h3index_eq'; +H3INDEX_NE: 'H3INDEX_NE' | 'h3index_ne'; +H3INDEX_LT: 'H3INDEX_LT' | 'h3index_lt'; +H3INDEX_LE: 'H3INDEX_LE' | 'h3index_le'; +H3INDEX_GT: 'H3INDEX_GT' | 'h3index_gt'; +H3INDEX_GE: 'H3INDEX_GE' | 'h3index_ge'; +H3INDEX_CMP: 'H3INDEX_CMP' | 'h3index_cmp'; GEOM_RELATE_PATTERN: 'GEOM_RELATE_PATTERN' | 'geom_relate_pattern'; GEOM_INTERSECTS2D: 'GEOM_INTERSECTS2D' | 'geom_intersects2d'; GEOM_DWITHIN2D: 'GEOM_DWITHIN2D' | 'geom_dwithin2d'; diff --git a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp index 9ae515ab44..7275e9ccae 100644 --- a/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp +++ b/nes-sql-parser/src/AntlrSQLQueryPlanCreator.cpp @@ -544,6 +544,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -11353,6 +11360,69 @@ void AntlrSQLQueryPlanCreator::exitFunctionCall(AntlrSQLParser::FunctionCallCont return LogicalFunction(AdwithinTgeoTgeoLogicalFunction(std::move(arg0), std::move(arg1), std::move(arg2), std::move(arg3), std::move(arg4), std::move(arg5), std::move(arg6))); } /* END CODEGEN PARSER GLUE: ADWITHIN_TGEO_TGEO */ + case AntlrSQLParser::H3INDEX_EQ: { + PRECONDITION(ctx->functionParam().size() == 2, + "H3indexEq requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(H3indexEqLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: H3INDEX_EQ */ + case AntlrSQLParser::H3INDEX_NE: { + PRECONDITION(ctx->functionParam().size() == 2, + "H3indexNe requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(H3indexNeLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: H3INDEX_NE */ + case AntlrSQLParser::H3INDEX_LT: { + PRECONDITION(ctx->functionParam().size() == 2, + "H3indexLt requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(H3indexLtLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: H3INDEX_LT */ + case AntlrSQLParser::H3INDEX_LE: { + PRECONDITION(ctx->functionParam().size() == 2, + "H3indexLe requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(H3indexLeLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: H3INDEX_LE */ + case AntlrSQLParser::H3INDEX_GT: { + PRECONDITION(ctx->functionParam().size() == 2, + "H3indexGt requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(H3indexGtLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: H3INDEX_GT */ + case AntlrSQLParser::H3INDEX_GE: { + PRECONDITION(ctx->functionParam().size() == 2, + "H3indexGe requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(H3indexGeLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: H3INDEX_GE */ + case AntlrSQLParser::H3INDEX_CMP: { + PRECONDITION(ctx->functionParam().size() == 2, + "H3indexCmp requires 2 args but got {}", + ctx->functionParam().size()); + auto arg0 = visit(ctx->functionParam(0)).as(); + auto arg1 = visit(ctx->functionParam(1)).as(); + return LogicalFunction(H3indexCmpLogicalFunction(std::move(arg0), std::move(arg1))); + } + /* END CODEGEN PARSER GLUE: H3INDEX_CMP */ /* END CODEGEN PARSER GLUE: GEOM_RELATE_PATTERN */ /* END CODEGEN PARSER GLUE: GEOM_INTERSECTS2D */ case AntlrSQLParser::GEOM_DWITHIN2D: {